You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.

# Buggy version:
S = list(input())
lenS = len(S)
S = S + ['.']
K = 0
i = 1
ps = S[1]
for s in S:
    if s != ps:
        K = min(K, max(i, lenS-i))
        ps = s
    i += 1
print(K)

# Fixed version:
S = list(input())
lenS = len(S)
S = S + ['.']
K = lenS
i = 0
ps = S[0]
for s in S:
    if s != ps:
        K = min(K, max(i, lenS-i))
        ps = s
    i += 1
print(K)

# Buggy version:
S=input()
l=len(S)
if l%2==1:
    m=S[l//2]
    c=1
    for i in range l//2:
        if S[l//2-i-1]==m and S[l//2+i+1]==m:
            c+=2
        else:
            break
    ans=c+(l-c)//2
else:
    m1=S[l//2-1]
    m2=S[l//2]
    c=0
    if m1==m2:
        c=2
        for i in range l//2-1:
        if S[l//2-i-2]==m1 and S[l//2+i+1]==m1:
            c+=2
        else:
            break
    ans=c+(l-c)//2
print(ans)

# Fixed version:
S=input()
l=len(S)
if l%2==1:
    m=S[l//2]
    c=1
    for i in range(l//2):
        if S[l//2-i-1]==m and S[l//2+i+1]==m:
            c+=2
        else:
            break
    ans=c+(l-c)//2
else:
    m1=S[l//2-1]
    m2=S[l//2]
    c=0
    if m1==m2:
        c=2
        for i in range(l//2-1):
            if S[l//2-i-2]==m1 and S[l//2+i+1]==m1:
                c+=2
            else:
                break
    ans=c+(l-c)//2
print(ans)

# Buggy version:
S = input()

a = n
n = len(S)
for i in range(n-1):
    if S[i] != S[i+1]:
        a = min(a, max(i+1, n-i+1))

print(a)


# Fixed version:
S = input()

n = len(S)
a = n
for i in range(n-1):
    if S[i] != S[i+1]:
        a = min(a, max(i+1, n-i-1))

print(a)

# Buggy version:
s = input()

sl = list(s)
sl.append("2")

n = len(sl)
res=[]

temp =1
for i  in range(n-1):
    if sl[i+1] == sl[i]:
        temp +=1
    else:
        res.append(temp)
        temp = 1

resu = n-1

while len(res) >1:
    resu = min(resu,max(res[0],res[1:]))
    x = res.pop(1)
    res[0]  = res[0]+x    
"""
    if res[0] > sum(res[1:]):
        resu = min(resu,res[0])
        x = res.pop(1)
        res[0] = res[0]+x
    else:
        resu = min(resu,sum(res[1:]))
        x = res.pop(1)
        res[0] =res[0]+x
"""
print(resu)

# Fixed version:
s = input()

sl = list(s)
sl.append("2")

n = len(sl)
res=[]

temp =1
for i  in range(n-1):
    if sl[i+1] == sl[i]:
        temp +=1
    else:
        res.append(temp)
        temp = 1

resu = n-1
m = n-1

while len(res) >1:
    resu = min(resu,max(res[0],m-res[0]))
    x = res.pop(1)
    res[0]  = res[0]+x    
    
print(resu)

# Buggy version:
S = list(input())

def check(x):
    print(S[len(S)-x:x])
    for y in S[len(S)-x:x]:
        if y != S[len(S)-x]: break
    else:
        return True
    return False

def bisect(l,r):
    if r - l == 1: return l
    mid = (l+r) // 2
    if check(mid) == False:
        return bisect(l,mid)
    else:
        return bisect(mid,r)
print(bisect(1,len(S)+1))



# Fixed version:
S = list(input())

def check(x):
    #print(S[len(S)-x:x])
    for y in S[len(S)-x:x]:
        if y != S[len(S)-x]: break
    else:
        return True
    return False

def bisect(l,r):
    if r - l == 1: return l
    mid = (l+r) // 2
    if check(mid) == False:
        return bisect(l,mid)
    else:
        return bisect(mid,r)
print(bisect(0,len(S)+1))

# Buggy version:
s = input()
n = len(s)

l = 0
r = n//2 + 1

while r - l > 1:
    m = l + (r-l)//2
    d = n//2 - m
    print(s[d:n-d])
    if s[d:n-d].count("0") == 0 or s[d:n-d].count("1") == 0:
        l = m
    else:
        r = m

if n % 2 == 0:
    print(n//2+l)
else:
    print(n//2+l+1)


# Fixed version:
s = input()
n = len(s)

l = 0
r = n//2 + 1

while r - l > 1:
    m = l + (r-l)//2
    d = n//2 - m
    if s[d:n-d].count("0") == 0 or s[d:n-d].count("1") == 0:
        l = m
    else:
        r = m

if n % 2 == 0:
    print(n//2+l)
else:
    print(n//2+l+1)

# Buggy version:
S=input()
N=len(S)

b=[int(S[i]) for i in range(N)]
for i in range(1,N):
    b[i]+=b[i-1]
black=[0 for i in range(0,N+1)]
for i in range(0,N):
    black[i+1]=b[i]


def condition(K):
    if 2*K-1<N:
        return True
    else:
        if black[K]-black[N-K]==0 or black[K]-black[N-K]==N-2*K:
            return True
        else:
            return False

start=1
end=N
while end-start>1:
    test=(end+start)//2
    if condition(test):
        start=test
    else:
        end=test

if condition(end):
    print(end)
else:
    print(start)

# Fixed version:
S=input()
N=len(S)

b=[int(S[i]) for i in range(N)]
for i in range(1,N):
    b[i]+=b[i-1]
black=[0 for i in range(0,N+1)]
for i in range(0,N):
    black[i+1]=b[i]

def condition(K):
    if 2*K-1<N:
        return True
    else:
        if black[K]-black[N-K]==0 or black[K]-black[N-K]==2*K-N:
            return True
        else:
            return False

start=1
end=N
while end-start>1:
    test=(end+start)//2
    if condition(test):
        start=test
    else:
        end=test

if condition(end):
    print(end)
else:
    print(start)

# Buggy version:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
ls=len(s)
if ls%2==0:
    tmp=0
    for i in range(ls//2):
        if s[ls//2+i]==s[ls//2-1-i]:
            tmp+=1
        else:
            break
    print(ls//2+tmp)
else:
    tmp=1
    for i in range(ls//2):
        if s[ls//2+1+i]==s[ls//2-1-i]:
            tmp+=1
        else:
            break
    print(ls//2+tmp)

# Fixed version:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
ls=len(s)
kijun=s[ls//2]
if ls%2==0:
    tmp=0
    for i in range(ls//2):
        if kijun==s[ls//2+i]==s[ls//2-1-i]:
            tmp+=1
        else:
            break
    print(ls//2+tmp)
else:
    tmp=1
    for i in range(ls//2):
        if kijun==s[ls//2+1+i]==s[ls//2-1-i]:
            tmp+=1
        else:
            break
    print(ls//2+tmp)

# Buggy version:
s=input();l=[]
for i in range(len(s)-1):
 if s[i]!=s[i+1]:l+=[max(i,len(s)-i-1)]
print(min(l))

# Fixed version:
s=input();l=[];n=len(s)
for i in range(n-1):
 if s[i]!=s[i+1]:l+=[max(i+1,n-i-1)]
print(min(l)if l else n)

# Buggy version:
S = input()
c0 = S[len(S)//2]
r = S.find("1" if c0 == "0" else "0", len(S)//2)
if r < 0: r = len(S)//2
l = S.rfind("1" if c0 == "0" else "0", 0, len(S)//2)
l += 1
K = min(r, len(S)-l)
#print(l, r, K)
print(K)


# Fixed version:
S = input()
c0 = S[len(S)//2]
r = S.find("1" if c0 == "0" else "0", len(S)//2)
if r < 0: r = len(S)
l = S.rfind("1" if c0 == "0" else "0", 0, len(S)//2)
l += 1
K = min(r, len(S)-l)
#print(l, r, K)
print(K)

# Buggy version:
s=input()
ans=len(s)
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    ans=min(ans,max(i+1,len(s)-i))
print(ans)


# Fixed version:
s=input()
l=len(s)
ans=l
for i in range(l-1):
  if s[i]!=s[i+1]:
    tmp=max(i+1,l-i-1)
    ans=min(ans,tmp)
print(ans)

# Buggy version:
#s = input()
"""
s = '101'
s = '100000000'
s = '00001011'
"""
k = len(s)
for i in range(1, len(s)):
    if s[i-1] != s[i+1]:
        k = min(k, max(i, len(s)-i))
print(k)




# Fixed version:
s = input()
"""
s = '101'
s = '100000000'
s = '00001011'
"""
k = len(s)
for i in range(1, len(s)):
    if s[i-1] != s[i]:
        k = min(k, max(i, len(s)-i))
print(k)

# Buggy version:
S = input()

ans = 0
if len(S) % 2 == 0:
    ans = len(S)//2
    c = ans
    t = S[ans]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
else:
    ans = len(S)//2
    c = ans+1
    t = S[ans+1]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
print(ans)


# Fixed version:
S = input()

ans = 0
if len(S) % 2 == 0:
    ans = len(S)//2
    c = ans
    t = S[ans]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
else:
    ans = len(S)//2+1
    c = ans
    t = S[ans-1]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break

    ans = max(len(S)//2,ans)

print(ans)

# Buggy version:
s = input()

if len(s) == 1:


tmp = []
for i in range(len(s)-1):
        if s[i] != s[i+1]:
                tmp.append(max(i+1,len(s)-(i+1)))

if len(tmp) == 0:
        #元から全部同じ
        print(len(s))
else:
        print(min(tmp))

# Fixed version:
s = input()



tmp = []
for i in range(len(s)-1):
        if s[i] != s[i+1]:
                tmp.append(max(i+1,len(s)-(i+1)))

if len(tmp) == 0:
        #元から全部同じ
        print(len(s))
else:
        print(min(tmp))

# Buggy version:
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	s=list(io())
	if len(s)% 2==1:
		center=len(s)//2
		mm=s[center]
		ret=center
		for ca,cb in zip(s[:center-1:-1],s[center+1:]):
			#print(ca,cb)
			if ca == mm and cb == mm:
				ret += 1
			else:
				break
	else:
		center=len(s)//2
		ret=center
		mm=-1
		la=s[center:-1]
		lb=s[center:]
		for ca, cb in zip(la, lb):
			#print(mm,ca,cb, center)
			if (mm == ca or mm == -1) and ca == cb:
				ret+=1
				mm=ca
			else:
				break
	return ret

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

# Fixed version:
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	s=list(io())[:-1]
	if len(s)% 2==1:
		center=len(s)//2
		mm=s[center]
		ret=center+1
		la=s[center-1::-1]
		lb=s[center+1:]
		for ca,cb in zip(la,lb):
			#print(ca,cb,mm)
			if ca == mm and cb == mm:
				ret += 1
			else:
				break
	else:
		center=len(s)//2
		ret=center
		mm=-1
		la=s[center-1::-1]
		lb=s[center:]
		for ca, cb in zip(la, lb):
			if (mm == ca or mm == -1) and ca == cb:
				ret+=1
				mm=ca
			else:
				break
				
	if 0:
		print(la)
		print(lb)
		print(mm)
	return ret

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

# Buggy version:
s = input()
if len (s) % 2 == 1:
    l = r = (len(s) + 1) // 2
    k = l-1
else:
    l = len(s) // 2
    r = len(s) // 2 + 1
    k = l

while s[l-1] == s[r-1]:
    k += 1
    l -= 1
    r += 1
    if l - 1 < 0:
        break

print(k)

# Fixed version:
s = input()
if len (s) % 2 == 1:
    l = r = (len(s) + 1) // 2
    k = l-1
else:
    l = len(s) // 2
    r = len(s) // 2 + 1
    k = l
center = s[l-1]

while s[l-1] == center and s[r-1] == center:
    k += 1
    l -= 1
    r += 1
    if l - 1 < 0:
        break

print(k)

# Buggy version:
def solve(string):
    l = [s == "1" for s in string]
    l_r = l[::-1]
    index = 0
    h = len(string) // 2
    for i, (c, n, c_r, n_r) in enumerate(zip(l[:h], l[1:h + 1], l_r[:h], l_r[1:h + 1])):
        if c ^ n or c_r ^ n_r:
            index = i + 1
    print(len(string) - index)


if __name__ == '__main__':
    print(solve(input()))


# Fixed version:
def solve(string):
    l = [s == "1" for s in string]
    l_r = l[::-1]
    index = 0
    h = len(string) // 2
    for i, (c, n, c_r, n_r) in enumerate(zip(l[:h], l[1:h + 1], l_r[:h], l_r[1:h + 1])):
        if c ^ n or c_r ^ n_r:
            index = i + 1
    return str(len(string) - index)


if __name__ == '__main__':
    print(solve(input()))

# Buggy version:
s=input()
n=len(s)
ans=n
for i in range(n-1):
  if s[i+1]!=s[i]:   
    ans=min(ans,max(i,n-i-1))
print(ans)

# Fixed version:
s=input()
pre=s[0]
n=len(s)
ans=n
for i in range(n-1):
    if s[i]!=s[i+1]:
        ans=min(ans,max(i+1,n-(i+1)))
    pre=s[i]
print(ans)

# Buggy version:
s = input()
n = len(s)
k = 0
tmp = set()
while k * 2 < n and len(tmp) < 2:
    print(k)
    tmp.add(s[n // 2 + k])
    tmp.add(s[(n - 1) // 2 - k])
    k += 1
print(n // 2 + k - (len(tmp) == 2))

# Fixed version:
s = input()
n = len(s)
k = 0
tmp = set()
while k * 2 < n and len(tmp) < 2:
    tmp.add(s[n // 2 + k])
    tmp.add(s[(n - 1) // 2 - k])
    k += 1
print(n // 2 + k - (len(tmp) == 2))

# Buggy version:
 = input()
t = s[len(s)//2]
j = len(s)//2
i = len(s)-j-1
ans = j
while i >= 0:
    if s[i] != t or s[j] != t:
        break
    ans += 1
    i -= 1
    j += 1

print(ans)

# Fixed version:
s = input()
t = s[len(s)//2]
j = len(s)//2
i = len(s)-j-1
ans = j
while i >= 0:
    if s[i] != t or s[j] != t:
        break
    ans += 1
    i -= 1
    j += 1

print(ans)

# Buggy version:
s = list(map(int, list(input())))
ans = n
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        ans = min(ans, max(i+1, len(s)-i-1))
print(ans)


# Fixed version:
s = list(map(int, list(input())))

n = len(s)
ans = n
for i in range(1, n):
    if s[i] != s[i - 1]:
        ans = min(ans, max(i, n-i))

print(ans)

# Buggy version:
s = input()

i_flips = []
i = 0
for j in range(1, len(s)):
    if s[j] != s[i]:
        i_flips.append(j)
        i = j
print(i_flips)

if len(i_flips) == 0:
    print(len(s))
else:
    ans = len(s)
    for i in i_flips:
        ans = min(ans, max(i, len(s)-i))
    print(ans)


# Fixed version:
s = input()

i_flips = []
i = 0
for j in range(1, len(s)):
    if s[j] != s[i]:
        i_flips.append(j)
        i = j
# print(i_flips)

if len(i_flips) == 0:
    print(len(s))
else:
    ans = len(s)
    for i in i_flips:
        ans = min(ans, max(i, len(s)-i))
    print(ans)

# Buggy version:
S = input()
best = len(S)
for i in range(1, len(S)):
    if S[i-1] != S[i]:
        best = min(best, max(i, len(S) - 1))
print(best)

# Fixed version:
S = input()
K = len(S)
for i in range(1, len(S)):
    if S[i-1] != S[i]:
        K = min(K, max(i, len(S)-i))

print(K)

# Buggy version:
S = input()

s = S[0]
temp_T = 100000
for i in range(1, len(S)+1):
    if(S[i] != s):
        judge = max(i,len(S)-i)
        temp_T = min(judge, temp_T)
        s = S[i]

print(temp_T)


# Fixed version:
S = input()

# s = S[0]
temp_T = len(S)
for i in range(len(S)-1):
    if(S[i] != S[i+1]):
        judge = max(i+1,len(S)-(i+1))
        temp_T = min(judge, temp_T)

print(temp_T)

# Buggy version:
def ans():
    S = input()
    N = len(S)
    if not ('1' in S and '0' in S):
        return print(N)

    tmp = 1000000
    for i, v in enumerate(S):
        if i == 0:
            continue
        if S[i-1] != v:
            tmp = min(max(i, N-i), tmp)
    return print(tmp)


# Fixed version:
def ans():
    S = input()
    N = len(S)
    if not ('1' in S and '0' in S):
        return print(N)

    tmp = 1000000
    for i, v in enumerate(S):
        if i == 0:
            continue
        if S[i-1] != v:
            tmp = min(max(i, N-i), tmp)
    return print(tmp)

# main()
ans()

# Buggy version:
S=input()
if len(S)==1:
    print('1')
else:
    k=0
    L=[]
    while k < (len(S)-1):
        if S[k] != S[k+1]:
            L.append(max(k,len(S)-k))
            k += 1
        else:
            k += 1
    L.sort()
    print(L[0])

# Fixed version:
S=input()
if len(S)==1:
    print('1')
else:
    k=0
    L=[]
    while k < (len(S)-1):
        if S[k] != S[k+1]:
            L.append(max(k+1,len(S)-k-1))
            k += 1
        else:
            k += 1
    L.sort()
    if len(L)==0:
        print(len(S))
    else:
        print(L[0])

# Buggy version:
# -- coding: utf-8 --

binary = input()
n = len(binary)
k = n
for i in range(n - 1):
    if binary[i] != binary[i + 1]:
        k = min(k, max(i, n - i - 1))

print(k)

# Fixed version:
# -- coding: utf-8 --

binary = input()
n = len(binary)
k = n
for i in range(n - 1):
    if binary[i] != binary[i + 1]:
        k = min(k, max(i + 1, n - i - 1))

print(k)

# Buggy version:
s = input()
n = len(s)
t = s[::-1]
ans = n
for i in range(n-1):
  if s[i] != s[i+1]:
    ans = min(ans,max(i+2,n-i-1))
print(ans)

# Fixed version:
s = input()
n = len(s)

ans = n
for i in range(n-1) :
    if s[i] != s[i+1] :
        ans = min(ans, max(i+1, n-i-1))

print(ans)

# Buggy version:
S = input()

ans = len(S)
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        ans = min(ans, max(i, len(S)-i))

print(ans)


# Fixed version:
l = input()

ans = len(l)
for i in range(len(l)-1):
    if l[i] != l[i+1]:
        ans = min(ans, max(i+1, len(l)-i-1))

print(ans)

# Buggy version:
l=input()
n=len(l)

for i in range(1,n):
  x = n
  nx=0
  if l[i-1] != l[i]:
    nx = max(i, n-i)
  x = min(x,nx)
print(x)

# Fixed version:
l=input()
n=len(l)
x = n
for i in range(1,n):
  if l[i-1] != l[i]:
    nx = max(i, n-i)
    x = min(x,nx)
print(x)

# Buggy version:
if __name__=="__main__":
    l = list(input())
    N = len(l)
    pre = l[0]
    results = []
    for i in range(1,N):
        if not l[i]==pre:
            pre = l[i]
            results.append(max(i+1,N-i-1))
    print(min(results))

# Fixed version:
if __name__=="__main__":
    l = list(input())
    N = len(l)
    results = []
    for i in range(0,N-1):
        if not l[i]==l[i+1]:
            results.append(max(i+1,N-i-1))
    if len(results):
        print(min(results))
    else:
        print(N)

# Buggy version:
import math
S = input()
t = len(S)-1
L = S[:math.ceil(len(S)/2)]
R = S[len(S)//2:]
#print(L, R)
if L[-1] == R[0]:
  j = 0
  i = 1
  while i < len(L):
    if R[0] == R[i] and L[-i-1] == R[i]:
      j += 1
    i+=1
else:
  j = 0 
  
#print(j)
print(math.floor(len(S)/2) + j)

# Fixed version:
import math
S = input()
L = S[:math.ceil(len(S)/2)]
R = S[len(S)//2:]
#print(L, R)
if L[-1] == R[0]:
  j = 1
  i = 1
  while i < len(L):
    if R[0] == R[i] and L[-i-1] == R[i]:
      #print(-i-1, i)
      #print(L[-i-1], R[i])
      j += 1
      #print(j)
    else:
      break
    i+=1
    #print(i)
else:
  j = 0 
  
#print(j)
print(math.floor(len(S)/2) + j)