You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times.    * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`.
#from numpy import*
#from scipy import*
from collections import* 
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* 
from heapq import* 
from math import factorial
from copy import deepcopy
import sys

sys.setrecursionlimit(10**6)


def main():
    bound=0
    ans=[]
    s=input()
    if all(i=="0" for i in s):
        print(0)
        exit()
    for k,v in groupby(s):
        bound+=len(list(v))
#        ans.append()
        ans.append(max(bound,len(s)-bound))
    print(min(ans))
    
    
if __name__ == '__main__':
    main()
from itertools import*;s=input();print(min(max(len(s)-i,i)for i in accumulate(len(list(v))for k,v in groupby(s))))