Problem:
 Score : 500 points    Problem Statement 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 1 010      Sample Output 1 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 .        Sample Input 2 100000000      Sample Output 2 8       Sample Input 3 00001111      Sample Output 3 4

Solution (Python):
S = input()
t = len(S)
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        need = max(i+1,len(S)-i-1)
        t = min(need,t)
print(t)

Solution (Python):
s = input()

ans = len(s)
m = 1
for i in range(len(s)):
    if s[i]== str(m):
        if i<(len(s)+1)//2:
            ans = len(s)-i
            m = (m+1)%2
        else:
            ans = min(ans,i)

print(ans)

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    slen = len(s)

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


solve()

Solution (Python):



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

Solution (Python):
S=input()

from itertools import groupby, accumulate

_l = [len(list(g)) for k,g in groupby(S)]
_l_cs = [0] + list(accumulate(_l))
_l_cs_r = list(accumulate(_l[::-1]))[::-1] + [0]

answer = len(S)
for i, r in zip(_l_cs, _l_cs_r):
  answer = min(answer, max(i,r))

print(answer)

Solution (Python):
s = input()
k = len(s)
for i in range(1, len(s)):
    if s[i] != s[i - 1]:
        m = max(i, len(s) - i)
        if m < k:
            k = m
print(k)

Solution (Python):
S=input()

b = S[0]
n=len(S)
res=10**9
if("1" not in S):
    print(n)
    exit()
if("0" not in S):
    print(n)
    exit()
for i in range(1,n):
    if S[i]!=b:
        res=min(res,max(i,n-(i)))
    b=S[i]

print(res)

Solution (Python):



import sys
import math


s = str(input())
n = len(s)
sn = []
cont = 1
for i in range(1,n):
  if s[i-1] != s[i]:
    sn.append(cont)
    cont = 1
  else:
    cont += 1
sn.append(cont)


sm_l = 0
for i in sn:
  if sm_l < (n+1)//2:
    sm_l += i


sn = reversed(sn)
sm_r = 0
for i in sn:
  if sm_r < (n+1)//2:
    sm_r += i

print(min(sm_l,sm_r))

Solution (Python):
S = input()
ans = float('inf')
for i in range(len(S)-1):
  if S[i] != S[i+1]:
    k = max(i+1,len(S)-i-1)
    if k <= ans:
      ans = k
if ans != float('inf'):
  print(ans)
else:
  print(len(S))

Solution (Python):
s = input()
n = len(s)

left = 0
right = n-1
ans = [-1 for i in range(n)]

def judge(m):
    if n>=2*m:
        return 1

    for i in range(n-m,m-1):
        if s[i] != s[i+1]:
            return 0
    return 1

while left <= right:
    mid = (left+right)//2
    

    if judge(mid+1):
        ans[mid]  = 1
        left = mid+1

    else:
        ans[mid]  = 0
        right = mid-1


for i in range(n):
    if ans[-i-1] ==1:
        print(n-i)
        break

Solution (Python):
S = input()
n = len(S)
ans = n

num = S[0]
for i in range(n):
    if num != S[i]:
        ans = min(ans,max(i,n-i))
        num = S[i]
print(ans)

Solution (Python):
S = list(input())
N = len(S)

if N % 2 == 0:
    n = int(N // 2)
    K = n
    i = 0
    while i < n:
        if S[n - 1 - i] == S[n + i]:
            i += 1
        else:
            break

    print(K + i)
else:
    n = int((N - 1) // 2)
    if N == 1:
        print(1)

    else:
        K = n + 1
        i = 0
        if S[n] == S[n + 1]:
            while i < n:
                if S[n - i - 1] == S[n + i + 1]:
                    i += 1
                else:
                    break
        print(K + i)

Solution (Python):
s = input().strip()

ans = len(s)
for i, (prevs, _s) in enumerate(zip(s, s[1:])):
  if prevs != _s:
    ans = min(ans, max(i+1, len(s)-i-1))
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

s = input()

K = float('inf')
if all(c == '0' for c in s):
    K = len(s)
elif all(c == '1' for c in s):
    K = len(s)
else:
    for k in range(1, len(s)):
        if s[k] != s[k-1]:
            K = min(K, max(k, len(s)-k))
        else:
            continue

print(K)

Solution (Python):
S=input()

l=len(S)

if l%2==0:
    count=l//2
    a=S[l//2-1]
    for i in range(l//2):
        if S[l//2-1-i]==a and S[l//2+i]==a:
            count+=1
        else:
            break
    print(count)
else:
    count=l//2+1
    a=S[l//2]
    for i in range(l//2):
        if S[l//2-1-i]==a and S[l//2+1+i]==a:

            count+=1
        else:
            break
    print(count)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

S = input()
size = len(S)
if len(S) % 2 == 0:
    ans = size // 2
    base = S[size // 2]
    for i in range(size // 2):
        if S[size // 2 - 1 - i] == S[size // 2 + i] == base:
            ans += 1
        else:
            break
    print(ans)
else:
    ans = size // 2 + 1
    base = S[size // 2]
    for i in range(size // 2):
        if S[size // 2 - 1 - i] == S[size // 2 + 1 + i] == base:
            ans += 1
        else:
            break
    print(ans)

Solution (Python):
a = list(input())
n = len(a)
a = [0] + a
s = n
for i in range (1, n):
    if(a[i] != a[i + 1]):
        s = min(s, max(i, n - i))
print(s)

Solution (Python):
s = list(input())
s = list(map(int, s))

length = len(s)
i = 0
while i < len(s) - 1:
    if s[i] != s[i+1]:
        length = min(length, max(i+1, len(s) - i - 1))
    i += 1
print(length)

Solution (Python):
s=input()
N=len(s)
ans=N//2
for i in range(N//2+1,N):
  if s[N-i:i]=="0"*(2*i-N) or s[N-i:i]=="1"*(2*i-N):
    ans=i
if s=="0"*N or s=="1"*N:
  ans=N
print(ans)

Solution (Python):
def main():
    buf = input()
    S = buf
    K = len(S) // 2
    center_char = S[K]
    while K < len(S):
        if S[K] == center_char and S[-K - 1] == center_char:
            K += 1
        else:
            break
    print(K)

if __name__ == '__main__':
    main()

Solution (Python):

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

Solution (Python):
S=input()
prev=S[0]
T=len(S)
for i in range(1, len(S)):
    if S[i]!=prev:
        T=min(T,max(i,len(S)-i))
        prev=S[i]
print(T)

Solution (Python):

s = list(input())
n = len(s)
res = 10**6

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

if res==10**6:
    res = n
print(res)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):

import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]
    count = 0
    N = len(S)
    if len(S) % 2 == 0:
        for i  in range(0, N/2):
            if S[N/2] == S[N/2 - i - 1]  and S[N/2] == S[N/2 + i]:
                count += 2
            else:
                break

    else:
        count += 1
        for i in range(1, N/2 + 1):
            if S[N/2] == S[N/2 - i] and S[N/2] == S[N/2 + i]:
                count += 2
            else:
                break

    K = N -(N - count)/2

    print K

if __name__ == '__main__':
    main()

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

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

S = raw_input()

mid = len(S) / 2
c = S[mid]
ans = mid

for i in range((len(S) + 1) / 2):
    pos1 = len(S) / 2 + i
    pos2 = (len(S) - 1) / 2 - i
    if c == S[pos1] == S[pos2]:
        ans += 1
    else:
        break

print ans

Solution (Python):
S=list(input())

K=(len(S)+1)//2

if len(S)%2==0:
  mark=S[len(S)//2]
  if mark!=S[len(S)//2-1]:
    print(K)
    exit()
  count=1
  while(0<len(S)-K-count):
    if mark!=S[len(S)//2-1-count] or mark!=S[len(S)//2+count]:
      print(K+count)
      exit()
    count+=1
  print(K+count)
else:
  mark=S[len(S)//2]
  count=0
  while(0<len(S)-K-count):
    if mark!=S[len(S)//2-1-count] or mark!=S[len(S)//2+1+count]:
      print(K+count)
      exit()
    count+=1
  print(K+count)

Solution (Python):
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import *

S = input()
N = len(S)

def solvable(k):
  imos = [0] * (N+1)
  ops = [0] * (N+1)
  for i in range(N-k+1):
    ops[i] = ops[i-1] + imos[i]
    if int(S[i] == '1') ^ (ops[i] & 1):
      imos[i] += 1
      imos[i+k] -= 1
      ops[i] += 1
  ops = list(accumulate(imos))[:-1]
  return not any(int(S[i] == '1') ^ (ops[i] & 1) for i in range(k))

l = 1
r = N+1
while r - l > 1:
  m = (l + r) // 2
  if solvable(m):
    l = m
  else:
    r = m
print(l)

Solution (Python):


def main():
    s = input()
    n = len(s)
    chs = changes(s, n)

    res = n
    for c in chs:
        di = max(c, n - c)
        res = min(res, di)

    print(res)

def changes(s, n):
    res = []
    for i in range(1, n):
        if s[i - 1] != s[i]:
            res.append(i)
    return res

main()

Solution (Python):
import sys
S = [1 if i =='1' else 0 for i in input()]
l=len(S)
if l%2==1:
    t=l//2
    a = S[t]
    for i in range(1,t+1):
        if S[t-i]!=a or S[t+i]!=a:
            print(t+i)
            sys.exit()
    print(l)
    sys.exit()
if l%2==0:
    t=l//2
    a = S[t-1]
    b=S[t]
    if a!=b:
        print(t)
        sys.exit()
    for i in range(1,t):
        if S[t-1-i]!=a or S[t+i]!=a:
            print(t+i)
            sys.exit()
    print(l)
    sys.exit()

Solution (Python):
s = input()
s = list(map(int, list(s)))
 
now = s[0]
cnt = 0
stack = []
for e in s:
    if now == e:
        cnt += 1
    else:
        stack.append(cnt)
        cnt = 1
        now = e
stack.append(cnt)
 

 
l = len(stack)
ans = int(1e18)
if l == 1:
    ans = len(s)
else:
    cnt = 0
    for i in range(l):
        cnt += stack[i]
        ans = min(ans, max(cnt, len(s)-cnt))
 
print(ans)

Solution (Python):
S = list(map(int, list(input())))
n = len(S)

if len(set(S)) == 1:
	print(len(S))
else:
	ans = 1000000
	for i in range(n-1):
		if S[i] != S[i+1]:
			m = max(n - i - 1, i + 1)
			if m < ans:
				ans = m

	print(ans)

Solution (Python):


import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq





def solve(f):
    s = f.read_str()
    n = len(s)
    if n % 2 == 0:
        if s[n/2-1] != s[n/2]: return n/2
        c = s[n/2]
        ans = n/2
        for i in xrange(n/2-1, -1, -1):
            if s[i] != c or s[n-i-1] != c: break
            ans += 1
        return ans
    else:
        c = s[n/2]
        ans = n/2 + 1
        for i in xrange(n/2-1, -1, -1):
            if s[i] != c or s[n-i-1] != c: break
            ans += 1
        return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case 
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Solution (Python):
S = input()
N = len(S)

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

ans = N//2
l = r = N//2
if N%2 == 0: l -= 1

inside = None
while l >= 0:
    if not inside:
        if N%2:
            if S[l] == 1:
                print(N//2 + 1)
                exit()
        else:
            if S[l] != S[r]:
                print(N//2)
                exit()
        inside = S[l]
        continue
    if S[l] != inside or S[r] != inside:
        break
    inside = S[l]
    l -= 1
    r += 1
    ans += 1
print(ans)

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

Solution (Python):
s= raw_input()
def solve():
    prev = s[0]
    ans = len(s)
    for i in range(0,len(s)):
        if prev != s[i]:
            ans = min(ans,max(i,len(s)-i))
            prev = s[i]
    print ans
solve()

Solution (Python):
S = input()
N = len(S)
for k in range((N+1)//2, N):
    if S[k-1] != S[k] or S[-k] != S[-k-1]:
        print(k)
        break
else:
    print(N)

Solution (Python):

S = input()
for k in range((len(S)+1)//2-1, len(S)-1):
    if S[k] != S[k+1] or S[-k-1] != S[-k-2]:
        print(k+1)
        break
else:
    print(len(S))

Solution (Python):
S = input()

i = len(S)//2
j = i - 1 + len(S)%2
v = S[i]

while j >= 0 and S[i] == S[j] == v :
    i += 1
    j -= 1

res = len(S) - j - 1
print(res)

Solution (Python):

def ok(S, K):
    s = ''
    for i in range(len(S)):
        if i < K and i >= len(S) - K:
            s += S[i]

    if s == '':
        return True
    return all([c == s[0] for c in s])


S = input()
lb = 1
ub = len(S) + 1
while ub - lb > 1:
    mid = (ub + lb) // 2
    if ok(S, mid):
        lb = mid
    else:
        ub = mid

print(lb)

Solution (Python):

S = input()
n = len(S)
L = list(map(int, list(S)))
D = []
res = 0
for k in range(n-1):
    if L[k] != L[k+1]:
        D.append(max(k+1, n-k-1))

if len(D):
    print(min(D))
else:
    print(n)

Solution (Python):
from collections import Counter

item = str(input())
longest = [0,0]
shortest = [len(item),len(item)]
current = 1

def exchange(item):
    for i in range(1, len(item)):
        if item[i-1] != item[i]:
            return max(exchange(item[0:i]), exchange(item[i:]))
    return len(item)

N = len(item)
T = N
for k in range(1, N):
    if item[k-1] != item[k]:
        tmp = max(k, N-(k))
        if T >= tmp:
            T = tmp

print(T)

Solution (Python):
S=input()
length=len(S)

wk=length
bk=length
for i, s in enumerate(S):
    cost=max(i, length-(i+1))
    if s == "0":
        wk = min(wk, cost)
    else:
        bk = min(bk, cost)
print(max(wk, bk))

Solution (Python):
s, o = raw_input(), float('inf')
for i in xrange(len(s) - 1):
    if s[i] != s[i + 1]:
        o = min(o, max(i + 1, len(s) - i - 1))
print o if o != float('inf') else len(s)

Solution (Python):
inp = input()
nStr = len(inp)
ret = nStr//2


if(inp[nStr//2] == "1"):
    for i in reversed(range((nStr-1)//2 + 1)):
        if((inp[i] == inp[nStr-i-1]) and (inp[i] == "1")):
            ret += 1
        else:
            break
    print(ret)

else:            
    for i in reversed(range((nStr-1)//2 + 1)):
        if((inp[i] == inp[nStr-i-1]) and (inp[i] == "0")):
            ret += 1
        else:
            break
    print(ret)

Solution (Python):


S = input()
n = len(S)
T = []

for i in range(len(S)-1):
    if S[i] != S[i+1]:
        t = max(i+1, n-i-1)
        T.append(t)
if len(T) == 0:
    print(n)
else:
    print(min(T))

Solution (Python):
s=raw_input()
k=len(s)/2+1
lef=(len(s)-1)/2
ch=s[lef]
rig=(len(s))/2
while 0<=lef and rig<len(s):
    if s[lef]==s[rig] and ch==s[lef]:
        k+=1
        lef-=1
        rig+=1
    else:
        k-=1
        break
print(k-(lef==-1))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    l = len(s)
    a = [c == '1' for c in s]
    r = l//2 + l%2
    b = l//2 - 1
    c = l//2 + l%2
    for i in range(b+1):
        if a[b-i] != a[b-i+1] or a[c+i] != a[c+i-1]:
            break
        r += 1

    return r



print(main())

Solution (Python):
def main():
    s = input()

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

if __name__ == '__main__':
    main()

Solution (Python):
S = input()
N = len(S)


if N % 2 == 1:
    mid = N // 2
    K = N
    for i in range(mid):
        if S[mid] != S[mid + i + 1]:
            K = min(K, N - mid + i)
            break
    for i in range(mid):
        if S[mid] != S[mid - i - 1]:
            K = min(K, N - mid + i)
            break

if N % 2 == 0:
    mid_right = N // 2
    mid_left = N // 2 - 1
    K = N
    for i in range(N // 2):
        if S[mid_left] != S[mid_left + i + 1]:
            K = min(K, N//2 + i)
            break
    for i in range(N // 2):
        if S[mid_right] != S[mid_right - i - 1]:
            K = min(K, N//2 + i)


print(K)

Solution (Python):
s = str(input())
n = len(s)

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

Solution (Python):
s = input()

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

print(ans)

Solution (Python):
s=input()
cnt=len(s)//2
i=0
if len(s)%2:
    while cnt+i<len(s) and s[cnt-i]==s[cnt+i]==s[cnt]:
        i+=1
else:
    while cnt+i<len(s) and s[cnt-i-1]==s[cnt+i]==s[cnt]:
        i+=1
print(cnt+i)

Solution (Python):
s=input()
cnt=len(s)//2
i=0
if len(s)%2:
    while cnt+i<len(s) and s[cnt-i]==s[cnt+i]==s[cnt]:
        i+=1
else:
    while cnt+i<len(s) and s[cnt-i-1]==s[cnt+i]==s[cnt]:
        i+=1
print(cnt+i)

Solution (Python):
S=raw_input()
n=len(S)
S=S+"0"
ans=n
for i in xrange(n) :
    if S[i]!=S[i+1] :
        ans=min(ans,max(i+1,n-1-i))
print ans

Solution (Python):
S = input()


def kaisetsu(S):
    n = len(S)
    K = n
    for i in range(n - 1):
        if S[i] != S[i + 1]:
            k = max(i + 1, n - i - 1)
            K = min(K, k)
    return K
 

print(kaisetsu(S))

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

Solution (Python):



def solve():
    s = input()
    n = len(s)

    ans = len(s)
    current_number = s[0]
    for k, c in enumerate(s):
        if c != current_number:
            ans = min(ans, max(k, n - k))
            current_number = c
    print(ans)

if __name__=="__main__":
    solve()

Solution (Python):
import numpy as np 
s = input()
fis = s[0]
n = len(s)
k = n
temp = s[0]
for i in range(n):
    if temp!=s[i]:
        temp = s[i]
        k = np.min((k, np.max( (i, n-i) ) ))
print("{}".format(int(k)))

Solution (Python):
'''input
010
'''

def list_input():
    return list(map(int,input().split()))
def map_input():
    return map(int,input().split())
def map_string():
    return input().split()
    
s = input()
n = len(s)
l = (n-1)//2
r = n//2
ans = n//2
cur = s[l]
while l >= 0:
	if s[l] == s[r] and s[l] == cur:
		ans += 1
		l -= 1
		r += 1
	else: break
print(ans)

Solution (Python):
S = input()
INF = 10000000000000
T_S = INF
N = len(S)
for i in range(N - 1):
    if S[i] != S[i + 1]:
        T_S = min(T_S, max(i + 1, N - i - 1))
if T_S == INF:
    print(N)
else:
    print(T_S)

Solution (Python):
S = input()
N = len(S)

m = N//2
if N%2 == 0:
    if S[m] != S[m-1]:
        print(m)
        exit()
    ans = m+1
    for i in range(1,m):
        if S[m] == S[m+i] == S[m-1-i]:
            ans += 1
        else:
            break
else:
    ans = m+1
    for i in range(1,m+1):
        if S[m] == S[m+i] == S[m-i]:
            ans += 1
        else:
            break
print(ans)

Solution (Python):
s = input()

l = len(s)

t = l

for i,x in enumerate(s):
    if i == 0:
        pass
    else:
        if x != s[i-1]:
            a = max(i,l-i)
            t = min(t,a)

print(t)

Solution (Python):
s = input()

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

Solution (Python):
S = input()
if all(S[0] == x for x in S):
    print(len(S))
else:
    print(min(max(i + 1, len(S) - (i + 1)) for i in range(len(S) - 1) if S[i] != S[i + 1]))

Solution (Python):
s = list(input())

ans = min(1, len(s) // 2)
prev = -1
for i in range(ans, len(s) + 1):
    m_b = len(s) - i
    m_e = i
    is_ok = True
    if m_b < m_e:
        m_e = m_e - 1
        if prev == -1:
            prev = s[m_b]
        if prev != s[m_b] or prev != s[m_e]:
            is_ok = False
    if is_ok:
        ans = i
    else:
        break
print(ans)

Solution (Python):

s = input()
now = s[0]
cnt = 1
use = []
for i in range(1,len(s)):
    if now == s[i]:
        cnt += 1
    else:
        use.append(cnt)
        cnt = 1
        now = s[i]
use.append(cnt)

min_prob = len(s)
sum_s = sum(use)
def ketsugou(l):
    global min_prob
    global sum_s
    
    m = l.index(min(l))
    if m == 0 or m == len(l) - 1:
        s1 = l[m]
        s2 = sum_s - l[m]
        min_prob = min(min_prob, max(s1, s2))
        if m == 0:
            l = l[1:]
            l[0] += s1
        else:
            l.pop()
            l[-1] += s1
    else:
        s1 = sum(l[:m])
        s2 = s1 + l[m]
        s3 = sum_s - s1
        s4 = sum_s - s2
        min_prob = min(min_prob, max(s1, s2,s3,s4))
        if l[m - 1] < l[m + 1]:
            l[m - 1] += l[m]
        else:
            l[m + 1] += l[m]
        l.pop(m)


sum_ss = 0
for i in range(len(use)):
    sum_ss += use[i]
    min_prob = min(min_prob, max(sum_s - sum_ss, sum_ss))

print(min_prob)

Solution (Python):
Ss = input()

Ns = []
prev = Ss[0]
num = 0
for S in Ss:
    if S != prev:
        Ns += [num]
        num = 1
    else:
        num += 1
    prev = S

Ns += [num]

sumN = 0
restN = sum(Ns)
ans = float('inf')
for N in Ns:
    sumN += N
    restN -= N
    ans = min(ans, max(sumN, restN))

print(ans)

Solution (Python):
S = raw_input()
A = [0]
for i in range(len(S)-1):
  if S[i]!=S[i+1]:
    A += [i+1]
A += [len(S)]
B = [A[i+1]-A[i] for i in range(len(A)-1)]

s = sum(B)
ans = 0
l = 0
for b in B:
  ans = max(ans, min(l+b, s-l))
  l += b
print ans

Solution (Python):
S = list(map(int, list(input())))
lenS = len(S)
count0 = S.count(0)
if count0 == 0 or count0 == len(S):
	print(lenS)
	exit()

if lenS % 2 == 1:
	center = int(lenS/2)
	K = 1
	while K < center:
		if S[center-K] == S[center] and S[center + K] == S[center]:
			K += 1
			continue
		else:
			break
	K = center + K
else:
	center = int(lenS/2)
	K = 1
	while K < center:
		if S[center-K] == S[center+K-1] and S[center-K] == S[center]:
			K += 1
			continue
		else:
			break
	K = center + K - 1

print(K)
"""
def reverse(A, l, n):
	for x in range(n):
		A[l+x] = 1 - A[l+x]

L = int(lenS/2)
while L < R:
	K = int((L+R+1)/2)
	test = [i for i in S]
	for i in range(lenS - K + 1):
		if test[i] == 1:
			reverse(test, i, K)
	flag = True
	for i in range(K):
		if test[i] == 1:
			flag = False
			break
	if flag:
		L = K
	else:
		R = K - 1
		S = test
print(L)
"""

Solution (Python):
from collections import deque
arr = deque()
prev = None
num = 0
for c in input():
  if prev is not None and c != prev:
    arr.append(num)
    num = 0
  prev = c
  num += 1
arr.append(num)

while len(arr) > 2:
  if arr[0] > arr[-1]:
    v = arr.pop()
    v += arr.pop()
    arr.append(v)
  else:
    v = arr.popleft()
    v += arr.popleft()
    arr.appendleft(v)

print(max(arr))

Solution (Python):
s = input()

if len(s) % 2 == 0:
    c = 0
    m = len(s) // 2 - 1
    x = s[m]
    while c <= m and x == s[m-c] and x == s[m+1+c]:
        c += 1
    print(len(s) // 2 + c)
else:
    c = 0
    m = len(s) // 2
    x = s[m]
    while c < m and x == s[m-1-c] and x == s[m+1+c]:
        c += 1
    print(len(s) // 2 + c + 1)

Solution (Python):
S = input()
cnt = 0

i = len(S)//2
j = i - 1 + len(S)%2 
v = S[i]

while j >= 0 and S[i] == S[j] == v:
  i += 1
  j -= 1

res = len(S) - j - 1
print(res)

Solution (Python):
def solve(s):
    n = len(s)

    if n == 1:
        return 1
    if n == 2:
        return 2 if s[0] == s[1] else 1

    ci = n // 2
    c = s[ci]
    if n & 1:
        for di in range(1, ci + 1):
            if c == s[ci - di] == s[ci + di]:
                pass
            else:
                return ci + di
        return n
    if c != s[ci - 1]:
        return ci
    for di in range(1, ci):
        if c == s[ci - di - 1] == s[ci + di]:
            pass
        else:
            return ci + di
    return n


print(solve(input()))

Solution (Python):
s = input().strip()
n = len(s)

ansone, anszero = n, n
for i, c in enumerate(s):
    ld, rd = i, n - i - 1
    if c == '1':
        ansone = min(ansone, max(ld, rd))
    else:
        anszero = min(anszero, max(ld, rd))
print(max(ansone, anszero))