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

S = eval(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)
# -*- coding: utf-8 -*-

S = eval(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)))
# -*- coding: utf-8 -*-
S = eval(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)

# -*- coding: utf-8 -*-
S = eval(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)))

-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))) +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 -    print(n) +    print((len(S)))