using System; using System.Numerics; class SimpleLoops { static void Main() { BigInteger t1 = int.Parse(Console.ReadLine()); BigInteger t2 = int.Parse(Console.ReadLine()); BigInteger t3 = int.Parse(Console.ReadLine()); BigInteger n = int.Parse(Console.ReadLine()); BigInteger Tn = t3 + t2 + t1; if (n < 4) { if (n == 1) { Tn = t1; } else if (n == 2) { Tn = t2; } else { Tn = t3; } } else { for (int i = 4; i < n; i++) { t1 = t2; t2 = t3; t3 = Tn; Tn = t3 + t2 + t1; } } Console.WriteLine(Tn); } }