Try our new interface for solving problems

Tale about an apple

Tale about an apple

prb2060-1 Once the king gave the farmer an apple from his garden. Farmer went to the garden and sees: the entire garden is surrounded with n fences, each fence has only one gate, and at each gate stands a guard. The farmer came to the first guard and showed him the royal decree, and guard said to him: "*Go and take, but when you return, give me half of your apples plus one*". The same was said by the second, third guard, etc. How many apples must take the farmer to pay all the guards and leave only one apple for himself?


The only number n – the number of fences in the garden (1n62).


The number of apples, which should take the farmer to pay off all the guards a leave one apple for himself.

Time limit 1 second
Memory limit 122.08 MiB
Input example #1
Output example #1
Input example #2
Output example #2
Author Анатолий Присяжнюк
Source Open and Distance Olympiads 2011-2012