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.

-----Constraints-----
 - 1\leq |S|\leq 10^5
 - S_i(1\leq i\leq N) is either 0 or 1.

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
Print the maximum integer K such that we can turn all the characters of S into 0 by repeating the operation some number of times.

-----Sample Input-----
010

-----Sample Output-----
2

We can turn all the characters of S into 0 by the following operations:
 - Perform the operation on the segment S[1,3] with length 3. S is now 101.
 - Perform the operation on the segment S[1,2] with length 2. S is now 011.
 - Perform the operation on the segment S[2,3] with length 2. S is now 000.

Difficulty: interview

Starter code:

Solutions:
import sys

readline=sys.stdin.readline

s=list(readline().strip())
n=len(s)
f=n%2
mid=s[n//2]

for i in range(n//2):
  if s[n//2-i-1]!=mid or s[(n+1)//2+i]!=mid:
    print(((n+1)//2+i))
    break
else:
  print(n)
  


import sys
sys.setrecursionlimit(100000000)

def main():
    S = input()
    N = len(S)
    ans = 0
    before = 0
    for i in range(N - 1):
        if S[i] != S[i + 1]:
            ans = max(ans,min(N - before,i + 1))
            before = i + 1
    ans = max(ans,N - before)
    print(ans)
def __starting_point():
    main()
__starting_point()

S = input()
L = len(S)
now = S[0]
ok = True
ans = 10**18
for i in range(1, L):
    if S[i] != now:
        now = S[i]
        ans = min(ans, max(i, L-i))
        ok = False
if ok:
    print(L)
else:
    print(ans)


s = input()
i = (len(s) - 1) // 2
j = len(s) // 2
k = s[i]
while i >= 0:
  if s[i] != k or s[j] != k:
    break
  i -= 1
  j += 1
if i <  0:
  print(len(s))
else:
  print(j)

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

import math
def f(s):
    if len(s)%2==0: p=len(s)//2-1
    else: p=len(s)//2
    
    q=p
    while  q<len(s) and s[p]==s[q]:
        q+=1
    return q



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

s=list(input())
l=[len(s)]
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    l.append(max(i+1,len(s)-i-1))
print(min(l))

s = input()
lns = len(s)
r = lns
for i, (b, c) in enumerate(zip(s, s[1:])):
    if b != c:
        r = min(r, max(i+1, lns-i-1))
print(r)


S = input()
l = len(S)
ans = l
"""
if len(set(list(S))) == 1 and S[0] == "0":
    print(0)
    return
"""
for i in range(l-1):
    if S[i] != S[i+1]:
        ans = min(ans,max(l-i-1,i+1))
print(ans)

import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    m = n // 2
    if n & 1:
        l = s[m::-1]
        r = s[m:]
    else:
        l = s[m-1::-1]
        r = s[m:]
    base = l[0]

    cnt = m
    i = 0
    if n & 1:
        m += 1
    while i < m:
        if l[i] == r[i] == base:
            i += 1
            cnt += 1
        else:
            break
    return cnt
    
def __starting_point():
    ans = main()
    print(ans)
__starting_point()

import sys
readline = sys.stdin.readline

S = readline().rstrip()

ans = len(S)
for i in range(1,len(S)):
  if S[i] != S[i - 1]:
    longer = max(i, len(S) - i)
    if ans > longer:
      ans = longer
      
print(ans)

#dame 
def main():
    S = input()
    r = len(S)
    if S.count('0') == r:
        return r
    if S.count('1') == r:
        return r
    N = len(S)
    one = S[0] == '1'
    c = 0
    for i in range(N):
        if (S[i] == '1' and one) or (S[i] == '0' and not one):
            continue
        r = min(r, max(i, N-i))
        one = S[i] == '1'
    return r
print((main()))


S = list(input())
N = len(S)

K = N // 2

if N % 2 == 0:
    if S[K - 1] == S[K]:
        tmp = S[K - 1]
    else:
        print (K)
        return
    i = 0
    while i < K and S[K - 1 - i] == S[K + i] == tmp:
        i += 1
    print (K + i)
else:
    tmp = S[K]
    i = 1
    while i <= K and S[K - i] == S[K + i] == tmp:
        i += 1
    print (K + i)

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)

s = input()

half = (len(s)-1)//2

ans = half+1
c = s[half]
for x,y in zip(s[half+1:],s[half-(len(s)%2==1)::-1]):
    if x==c and y==c:
        ans += 1
    else:
        break
print(ans)

S=input()
n=len(S)
if n%2:
    m=n//2
    t=S[m]
    for i in range(m):
        if S[m+i+1]!=t or S[m-i-1]!=t:
            a=m+i+1
            break
    else:
        a=n
else:
    m=n//2
    t=S[m]
    for i in range(m):
        if S[m+i]!=t or S[m-i-1]!=t:
            a=m+i
            break
    else:
        a=n
print(a)

from itertools import groupby
S = input()
N = len(S)
G = [len(list(l)) for _, l in groupby(S)]
A = 0
for g in G:
    A += g
    if A >= (N+1) // 2:
        ans = min(A, N-A+g)
        print(ans)
        break

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

s = list(input())
l = len(s)
if l % 2 == 0:
    for i in range(l//2):
        a = s[l//2]
        if s[l//2 - 1 - i] != a or s[l//2 + i] != a:
            print(l//2 + i)
            return
else:
    for i in range(1, (l-1)//2 + 1):
        a = s[(l-1)//2]
        if s[(l-1)//2 - i] != a or s[(l-1)//2 + i] != a:
            print((l-1)//2 + i)
            return
print(l)

import sys
#input = sys.stdin.buffer.readline
 
def main():
    s = input()
    l = len(s)
    if "0" not in s or "1" not in s:
        print(l)
    else:
        ans = 10**6
        for i in range(l-1):
            if s[i] != s[i+1]:
                ans = min(ans,max(i+1,l-i-1))
        print(ans)
    
def __starting_point():
    main()

__starting_point()

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

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)


import numpy as np
S=str(input())
X=[]
c=1
for i in range(1,len(S)):
  if S[i]==S[i-1]:
    c +=1
  elif S[i]!=S[i-1]:
    X +=[c]
    c=1
  if i==len(S)-1:
    X +=[c]
if len(S)==1:
  X=[1]
if len(X)>=3:
  X=np.cumsum(X)
  t=float('inf')
  for i in range(len(X)-1):
    u=max(X[i],len(S)-X[i])
    t=min(u,t)
  answer=t
elif len(X)==1:
  answer=X[0]
elif len(X)==2:
  answer=max(X)
print(answer)

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


s = [int(i) for i in 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)


def find_cont(S):
    N=len(S)
    res=N
    for i in range(N-1):
        if S[i]!=S[i+1]:
            res=min([res,max(i+1,N-1-i)])
    return res
S=input()
print((find_cont(S)))



s=input()
cs=[]
cnt=1
pre=s[0]
for si in s[1:]:
  if si==pre:
    cnt+=1
  else:
    cs.append(cnt)
    pre=si
    cnt=1
cs.append(cnt)
n=len(s)
ans1=n
merge=0
no_merge=n
for i in range(len(cs)):
  merge+=cs[i]
  no_merge-=cs[i]
  tmp=max(merge,no_merge)
  ans1=min(ans1,tmp)
cs.reverse()
ans2=n
merge=0
no_merge=n
for i in range(len(cs)):
  merge+=cs[i]
  no_merge-=cs[i]
  tmp=max(merge,no_merge)
  ans2=min(ans2,tmp)
print((max(ans1,ans2)))



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

S=input()
l=len(S)
cnt=(l+1)//2
n=l-cnt
b=S[l//2]
if l%2==0:
    for i in range(n):
        if S[l//2-i-1]!=b or S[l//2+i]!=b:
            break
        cnt+=1
else:
    for i in range(n):
        if S[l//2-i-1]!=b or S[l//2+i+1]!=b:
            break
        cnt+=1
print(cnt)

def main():
    S = input()
    l = len(S)
    ans = l
    #データ加工
    for i, s in enumerate(S[1:]):
        if s != S[i]:
            ans = min(ans, max(i+1, l-1-i))
    print(ans)
    
main()

import math
def f(s):
    if len(s)%2==0: p=len(s)//2-1
    else: p=len(s)//2
    
    q=p
    while  q<len(s) and s[p]==s[q]:
        q+=1
    return q



s=input()

print(min(f(s),f(s[::-1])))

S = [0] + list(map(int, list(input())))
N = len(S) - 1

def change(s, c):
  if c == 0:
    return s
  else:
    return 1 - s

def check(k):
  count = [0] * (N+1)
  T = S.copy()
  for i in range(1, N+1):
    c = count[i-1]
    s = change(S[i], c)
    if i < N - k + 2:
      T[i] = 0
      if s == 1:
        count[i] = (c + 1) % 2
      else:
        count[i] = c        
    else:
      T[i] = s
      count[i] = c      
  n = 0
  for t in T[1:]:
    if t == 1:
      break
    n += 1
  return n >= k


left = 1 # True
right = N
while left + 1 < right:
  mid = (left + right) // 2
  if check(mid):
    left = mid
  else:
    right = mid

if right == N and check(N):
  print(N)
else:
  print(left)

S = input()
N = len(S)

def f(k):
    s = S[-k:k]
    if s == "":return False
    return s.count(s[0])!=len(s)

def binary_search(l,r,func):
    if func(l):return l-1
    if not func(r):return r
    while l+1<r:
        i = (l+r)//2
        if func(i):
            r = i
        else:
            l = i
    return l

print(binary_search(0,N,f))

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))


#!/usr/bin/env python3
import sys


def solve(S: str):
    N = len(S)
    m = N
    for i in range(N - 1):
        if S[i] != S[i + 1]:
            m = min(m, max(N - (i + 1), i + 1))
    print(m)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


def __starting_point():
    main()

__starting_point()

# solution

import io
import sys
import math

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

S = input()

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


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)




S = input()
N = len(S)

if len(set(S))==1:
  print(N)
  return

K = (N+1)//2
X = set()
if N&1:
  X = {S[K-1]}
  l = K-2
  r = K
else:
  X = set()
  l = K-1
  r = K
  
while l:
  X.add(S[l])
  X.add(S[r])
  if len(X)>1: break
  K += 1
  l -= 1
  r += 1

print(K)

s = input()

l = len(s)
ans = l
for i, (e1, e2) in enumerate(zip(s, s[1:]), 1):
    if e1 != e2:
        ans = min(ans, max(i, l - i))

print(ans)


s=input();n=r=len(s)
for k in range(n-1):
  if s[k]!=s[k+1]:
    r=min(r,max(k+1,n-k-1))
print(r)

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



#!/usr/bin/env python

# -*- coding: utf-8 -*-



s = input()

if len(s) % 2 == 0:
    number = s[len(s) // 2]
    other = s[len(s) // 2 - 1]
    p = len(s) // 2
    cnt = 0
    if number == other:
        cnt += 1
        for i in range(1, p):
            if s[p + i] == s[p - 1 - i] == number:
                cnt += 1
            else:
                break
    print((p + cnt))


else:
    number = s[len(s) // 2]
    cnt = 0
    p = len(s) // 2

    for i in range(1, len(s) // 2 + 1):
        if s[p - i] == s[p + i] == number:
            cnt += 1
        else:
            break
    print((p + 1 + cnt))


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)

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)


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)

s = input()
n = len(s)

key = []
count = 1
for i in range(n-1):
  if s[i] != s[i+1]:
    key.append(count)
    count = 1
  else:
    count += 1
key.append(count)

sum_key = sum(key)
ans = 10000000
for i in range(len(key)):
    if i != 0:
        key[i] += key[i-1]
    ans = min(ans, max(key[i], n-key[i]))
  

print(ans)

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)


s = input()
L = len(s)

l, r, p = 0, 0, s[L // 2]
if L % 2 == 0:
    l, r = L // 2 - 1, L // 2
else:
    l, r = L // 2, L // 2

cnt = 0
while l >= 0 and r < L and s[l] == s[r] == p:
    p = s[l]
    cnt += 1
    l -= 1
    r += 1

print((cnt + L // 2))


s=list(str(input()))
n=len(s)
ans=10**10
for i in range(n-1):
    if s[i]!=s[i+1]:
        ans=min(ans,max(i+1,n-i-1))

if ans==10**10:
    print(n)
else:
    print(ans)


S = input()
b = []
for i in range(len(S) - 1):
    if S[i:i + 2] == "01" or S[i:i + 2] == "10":
        b.append(len(S) - (i + 1) if i < len(S) // 2 else i + 1)

print((min(b) if len(b) != 0 else len(S)))


S=input()
N=len(S)
cnt=N
for i in range(N-1):
  if S[i]!=S[i+1]:
    a=i+1
    b=N-a
    c=max(a,b)
    cnt=min(c,cnt)
print(cnt)

#N = int(input())
S = str(input())
#X, Y = map(int, input().split())
#C = list(map(int, input().split()))
N  =len(S)
ans = N
for i in range(1, N):
  if S[i] != S[i - 1]:
    now = max(i, N - i)
    ans = min(ans, now)

print(ans)

S = input()
L = len(S)

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


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)

w=input()
a=[(i+1)*(j=="0") for i,j in enumerate(w)]
b=[(i+1)*(j=="1") for i,j in enumerate(w)]
l=len(w)
ma=a[0];mb=b[0]
for t in range(1,l+1):
	ma=max(ma,a[t-1])
	mb=max(mb,b[t-1])
	m=min(ma,mb)
	if l-m<t:
		print(t-1)
		return
print(l)

S = input()
cnt = [0]
now = '0'
for i in S:
    if now == i:
        cnt[-1] += 1
    else:
        cnt.append(1)
        now = i

ans = len(S)
sum = 0
for i in cnt:
    sum += i
    ans = min(ans, max(sum, len(S) - sum))
print(ans)

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+1,n-i-1))
print(ans)


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


s = str(input())
n = len(s)

if n == 1:
    print(1)
    return

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

if maxs != []:
    print(min(maxs))
else:
    print(n)

# D - Wide Flip

S = input()

N = len(S)
ans = N

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


S = list(input())
C = len(S)
for i in range(len(S) - 1):
    if S[i] != S[i + 1]:
        c = max(i + 1, len(S) - i - 1)
        C = min(C, c)
print(C)

def main():
    S = input()
    A = []
    i, t = 1, S[0]
    for s in S[1:]:
        if s != t:
            A.append(i)
            i = 1
            t = s
        else:
            i += 1
    A.append(i)

    m, l  = len(S), 0
    for a in A:
        t = max(l + a, len(S) - l - a)
        m = min(m, t)
        l += a
    return m

print((main()))


# [a,b] - [a,b) = {b} なので、端の方は自由。
# 中央が単色であるかを確認すればよい。

import numpy as np
arr = np.array([int(x) for x in input()])
arr_c = arr.cumsum()

N = arr.size

answer = 0

for K in range(N,0,-1):
  left = N-K
  right = K-1
  # [left,right]が単色であればよい
  if left >= right:
    answer = K
    break
  one_cnt = arr_c[right] - arr_c[left] + arr[left]
  zero_cnt = (right - left + 1) - one_cnt
  if one_cnt == 0 or zero_cnt == 0:
    answer = K
    break
    
print(answer)


S=list(input())
n=len(S)
ans=n
for _ in range(n-1):
	if S[_]!=S[_+1]:
		tmp=max(_+1,n-(_+1))
		ans=min(ans,tmp)

print(ans)


s=input();n=r=len(s)
for k in range(n-1):
  if s[k]!=s[k+1]: r=min(r,max(k+1,n-k-1))
print(r)

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)



from collections import deque

x, y = deque(), deque()
s = deque(list(input()))
n = len(s)
m = s[n // 2]
ans = (n + 1) // 2
for _ in range((n + 1) // 2):
    x.appendleft(s.popleft())
for _ in range(n // 2):
    y.appendleft(s.pop())
if n % 2 == 1:
    x.popleft()
for i in range(n // 2):
    if x[i] == y[i] == m:
        ans += 1
    else:
        break
print(ans)

s = list(input())
n = len(s)
if n % 2 == 0:
    for i in range(n//2):
        a = s[n // 2]
        if s[n // 2 - 1 - i] != a or s[n // 2 + i] != a:
            print(n // 2 + i)
            return
else:
    for i in range(1, (n - 1) // 2 + 1):
        b = s[(n-1)//2]
        if s[(n - 1) // 2 - i] != b or s[(n - 1) // 2 + i] != b:
            print((n-1)//2+i)
            return
print(n)

def main():
    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)


def __starting_point():
    main()
__starting_point()

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)

s = input()

n = len(s)
ans = n
for i in range(1, n):
    if s[i - 1] != s[i]:
        # left:  [0, i) -> length = i
        # right: [i, n) -> length = n - i
        ans = min(ans, max(i, n - i))

print(ans)


S = input()

N = len(S)
L = []
temp = S[0]
c = 1
for i in range(1, N-1):
    if S[i] == temp:
        c += 1
    else:
        L.append(c)
        c = 1
        temp = S[i]
if S[N-1] == temp:
    c += 1
else:
    L.append(c)
    c = 1
L.append(c)

ans = N
while len(L) >= 3:
    if L[0] > L[-1]:
        ans = min(ans, N-L[-1])
        L[-2] += L[-1]
        L.pop(-1)
    else:
        ans = min(ans, N-L[0])
        L[1] += L[0]
        L.pop(0)
        
if len(L) == 2:
    ans = min(ans, max(L))
    
print(ans)

S = input()
N = len(S)
ans = N

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

print(ans)

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

s = list(str(input()))

max_ = len(s)
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        left = i+1
        right = len(s)-left
        # print(left, right)
        tmp = max(left, right)

        max_ = min(max_, tmp)
print(max_)


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

import itertools
S = list(itertools.accumulate([0] + [int(_) for _ in input()]))
N = len(S) - 1
for i in range(N, 0, -1):
    if 2 * i < N:
        break
    if S[i] - S[N - i] in [0, 2 * i - N]:
        break
print(i)


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)))



S = input() + '#'

pressed = []

prev = S[0]
count = 0
for s in S:
    if s == prev:
        count += 1
    else:
        prev = s
        pressed.append(count)
        count = 1

left_cumsum = []
right_cumsum = []

cumsum = 0
for count in pressed:
    cumsum += count
    left_cumsum.append(cumsum)

cumsum = 0
for count in pressed[::-1]:
    cumsum += count
    right_cumsum.append(cumsum)

length = len(left_cumsum)

if length == 1:
    print(len(S)-1)
    return

change_k = [0] * length

for idx in range(1, length):
    k = right_cumsum[-idx-1]
    change_k[idx-1] = k

for idx in range(1, length):
    k = left_cumsum[-idx-1]
    change_k[-idx] = max(change_k[-idx], k)

ans1 = min(change_k[::2])
ans2 = min(change_k[1::2])
print(max(ans1, ans2))

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-1))
print(ans)

S = input()

## 0を基準として、0と1の境目を調べる
boundary = []
pre_state = '0'
for i in range(len(S)):
  if S[i] != pre_state:
    boundary.append(i)
    pre_state = S[i]
else:
  if S[-1] == '1':
    boundary.append(len(S))
    
if len(boundary) == 0:
  print((len(S)))
  return
    
## 答えは、端から一番遠い境目
lst = []
for i in range(len(boundary)):
  lst.append(max(boundary[i], len(S)-boundary[i]))
ans = min(lst)
print(ans)


s = input()
len_s = len(s)
ans = len_s // 2
center = ans
b = s[ans]
if len_s % 2:
  for i in range(center+1):
    if s[center-i] == s[center+i] == b:
      ans += 1
    else:
      break
else:
  for i in range(center):
    if s[center-1-i] == s[center+i] == b:
      ans += 1
    else:
      break
print(ans)


s = input()
n = len(s)
ans = n
s1 = s.count('1')
i = 0
while s1 != 0 and s1 != n:
  s1 -= int(s[i]) + int(s[i + n - 1])
  if n == 1:
    s1 += int(s[i])
  n -= 2
  ans -= 1
  i += 1
print(ans)


# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = list(input())
N = len(S)

ans = ceil(N, 2)
for i in range(ceil(N, 2), N):
    # 真ん中から始めて、反対側と一致してるかと、1つ前と一致しているか
    if not S[i] == S[N-1-i] == S[i-1]:
        break
    ans += 1
print(ans)


# D 3424320
S = input()
N = len(S)
center_i = N//2
center = S[center_i]

ans = N//2
l = r = center_i
if N%2==0:
    l -= 1
while l >= 0:
    if not (S[l] == center == S[r]):
        break
    l -= 1
    r += 1
    ans += 1
print(ans)

s = input()
n = len(s)
change_cnt = 0
prev_length = 1
length = 1
ans = n
for i in range(n - 1):
    if s[i] != s[i + 1]:
        ans = min(max(i + 1, n - (i+1)), ans)
print(ans)

slist=list(map(int,list(input())))
len_s=len(slist)

min_answer=len_s
for i in range(1,len_s):
  if slist[i-1]!=slist[i]:
    min_answer=min(min_answer,max(i,len_s-i))
    #print(i,len(slist)-i)

print(min_answer)

s = input()

l = len(s)
center = s[l // 2]
cnt = l % 2
for e1, e2 in zip(s[:l//2][::-1], s[l//2+l%2:]):
    if center == e1 == e2:
        cnt += 2
    else:
        break

ans = (l + cnt) // 2
print(ans)


s = list(map(int, list(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-1))
print(ans)


S = input()
MIN = 10 ** 8
flag = 1
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        flag = 0
        MIN = min(MIN, max(i + 1, len(S) - i - 1))
if flag:
    MIN = len(S)
print(MIN)

S = input()
L = len(S)

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


def rle(s):
    # ex. '01100011110' -> [1 2 3 4 1]
    before_c = s[0]
    ret = list()
    cnt = 0
    for c in s:
        if before_c == c:
            cnt += 1
        else:
            ret.append(cnt)
            before_c = c
            cnt = 1
    if cnt > 0:
        ret.append(cnt)
    return ret


def main():
    S = input()
    N = len(S)
    seq_cnt = rle(S)
    if len(seq_cnt) == 1:
        print(seq_cnt[0])
        return
    if len(seq_cnt) == 2:
        print(max(seq_cnt))
        return
    # cumsum
    cumsum_seq_cnt = [0 for _ in range(len(seq_cnt))]
    rev_cumsum_seq_cnt = [0 for _ in range(len(seq_cnt))]
    cumsum_seq_cnt[0] = seq_cnt[0]
    rev_cumsum_seq_cnt[0] = seq_cnt[-1]
    for i in range(1, len(seq_cnt)):
        cumsum_seq_cnt[i] = cumsum_seq_cnt[i-1] + seq_cnt[i]
        rev_cumsum_seq_cnt[i] = rev_cumsum_seq_cnt[i-1] + seq_cnt[-1-i]
    # search
    max_k = cumsum_seq_cnt[0]
    rev_max_k= rev_cumsum_seq_cnt[0]
    for i in range(1, len(seq_cnt)):
        k = cumsum_seq_cnt[i]
        if k <= N - cumsum_seq_cnt[i-1]:
            max_k = k
        rev_k = rev_cumsum_seq_cnt[i]
        if rev_k <= N - rev_cumsum_seq_cnt[i-1]:
            rev_max_k = rev_k
    print(max([max_k, rev_max_k]))


def __starting_point():
    main()
__starting_point()

#初めは0と1で多い方だと思った
#正確にやってはないけど連続する0or1より長くないとだめ
#上限が何かを考える
s=input()
l=len(s)

ans=1000000000000
for i in range(l-1):
    if s[i]!=s[i+1]:
        ne=max(i+1,l-i-1)
        ans=min(ans,ne)
if ans==1000000000000:
    print(l)
else:
    print(ans)



S = input()
length = len(S)
temp = []
for i in range(1,length):
    if S[i] != S[i-1]:
        temp.append(max(i , length - i))
if len(temp) == 0:
    print(length)
else:
    print(min(temp))

S = input()

l = (len(S)-1)//2
r = len(S)//2
m = S[l]
while l >= 0:
    if S[l] != m or S[r] != m:
        break
    l -= 1
    r += 1
if l < 0:
    print((len(S)))
else:
    print(r)



I = input()

n     = len(I)
left  = 0
right = n - 1

block_left_index  = 0
block_right_index = n

## Example:
## 000011000
## |     |
##    or
##     |    |
while left < right:
    if I[left] != I[left+1]:
        block_left_index = left+1
    if I[right] != I[right-1]:
        block_right_index = right
    left  += 1
    right -= 1

ans = min(n-block_left_index, block_right_index)
print(ans, flush=True)


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

def __starting_point():
    main()
__starting_point()

def main():
  S = input()
  j = 0
  m = S[0]
  ls = []
  for i in range(len(S)):
    if m!=S[i]:
      ls.append(i-j)
      j = i
      m = S[i]
  ls.append(len(S)-j)
  N = len(ls)
  if N<3:
    print(max(ls))
  else:
    ans = float('inf')
    sls = [ls[0]]
    for i in range(1,N):
      sls += [sls[-1]+ls[i]]
    ans = min(max(sls[i], sls[-1]-sls[i]) for i in range(N-1))
    print(ans)

def __starting_point():
  main()
__starting_point()

from itertools import groupby, accumulate

S = list(input())
n = len(S)
s = list(accumulate([len(list(j)) for i, j in groupby(S)]))
s = [max(i, n - i) for i in s]

print((min(s)))