ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

USU Open Personal Contest 2010

About     Problems     Submit solution     Judge status     Standings
Contest is over

I. Binary Palindrome

Time limit: 1.0 second
Memory limit: 64 MB
Let an integer n be given. Write the integers from 1 to n in binary notation successively from left to right. In the resulting string consisting of zeros and ones, choose a palindrome substring of maximal length. It is required to find the length of this substring.

Input

The only input line contains the integer n in binary notation (1 ≤ n ≤ 21 000 000).

Output

Output one line containing the required length.

Samples

inputoutput
101
5
10100
11

Notes

In the first sample, the string 11011100101 will be written (a variant of the longest palindrome is underlined).
Problem Author: Ilya Zvigintsev
Problem Source: XI USU Open Personal Contest (March 13, 2010)
To submit the solution for this problem go to the Problem set: 1761. Binary Palindrome