Time

10:45:36
11 Feb 2012
ACM-ICPC Thailand Southern Region Programming Contest 2011
Left: 4 hours 15 minutes
End: 11.02.2012 15:00
Leader: Informatimukas
Five for week 22
Left: 11 hours 15 minutes
End: 11.02.2012 22:00
Leader: NuM
Version for print

Cycle shifts

prb27

   Lets write the decimal integer N in binary notation and create all its left cycle shifts where first digit of the number goes to the end.

   For example, if N=11, than it will be 1011 in binary notation, cycle shifts are 0111, 1110, 1101, 1011. The maximal value M among all received numbers in such way will have the number 11102=1410.

   For the number N find the maximal value of M.


Specifications

   Input

   One number N (1N2·109).

   Output

   One number M.


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 10
Complexity: 15% 538/636
Classes: Number theory
My result: 1/1

Example

Example input

11

Example output

14


← New-year presents Problems Product →