#arc088b. [arc088_b]Wide Flip
[arc088_b]Wide Flip
Problem Statement
You are given a string consisting of 0
and 1
. Find the maximum integer not greater than such that we can turn all the characters of into 0
by repeating the following operation some number of times.
- Choose a contiguous segment \[l,r\] in whose length is at least (that is, must be satisfied). For each integer such that , do the following: if is
0
, replace it with1
; if is1
, replace it with0
.
Constraints
- is either
0
or1
.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum integer such that we can turn all the characters of into 0
by repeating the operation some number of times.
Sample Input 1
010
Sample Output 1
2
We can turn all the characters of into 0
by the following operations:
- Perform the operation on the segment S\[1,3\] with length . is now
101
. - Perform the operation on the segment S\[1,2\] with length . is now
011
. - Perform the operation on the segment S\[2,3\] with length . is now
000
.
Sample Input 2
100000000
Sample Output 2
8
Sample Input 3
00001111
Sample Output 3
4