S = eval(input())

if S.count('1') == 0 or S.count('0') == 0:

    print((len(S)))

    exit()



c = S[0]

len_s = len(S)

mx = len_s

for s in range(1,len_s):

    if c != S[s]:

        mx = min(mx, max(len_s -s, s))

    c = S[s]

print(mx)

# https://atcoder.jp/contests/abc083/submissions/1917434

# i i+1 が異なる場所は中間から探すだけでいい

s=eval(input())

a=s[(len(s)-1)//2::-1]

b=s[len(s)//2:]

if a[0]!=b[0]:

    print((len(s)//2))

else:

    c=str(1-int(a[0]))

    m = (a+c).find(c)

    n = (b+c).find(c)

    print((len(s)//2+min(m,n)))

S = eval(input())
if S.count("1") == 0 or S.count("0") == 0:
    print((len(S)))
    exit()
c = S[0]
len_s = len(S)
mx = len_s
for s in range(1, len_s):
    if c != S[s]:
        mx = min(mx, max(len_s - s, s))
    c = S[s]
print(mx)

# https://atcoder.jp/contests/abc083/submissions/1917434
# i i+1 が異なる場所は中間から探すだけでいい
s = eval(input())
a = s[(len(s) - 1) // 2 :: -1]
b = s[len(s) // 2 :]
if a[0] != b[0]:
    print((len(s) // 2))
else:
    c = str(1 - int(a[0]))
    m = (a + c).find(c)
    n = (b + c).find(c)
    print((len(s) // 2 + min(m, n)))

-S = eval(input()) -if S.count("1") == 0 or S.count("0") == 0: -    print((len(S))) -    exit() -c = S[0] -len_s = len(S) -mx = len_s -for s in range(1, len_s): -    if c != S[s]: -        mx = min(mx, max(len_s - s, s)) -    c = S[s] -print(mx) +# https://atcoder.jp/contests/abc083/submissions/1917434 +# i i+1 が異なる場所は中間から探すだけでいい +s = eval(input()) +a = s[(len(s) - 1) // 2 :: -1] +b = s[len(s) // 2 :] +if a[0] != b[0]: +    print((len(s) // 2)) +else: +    c = str(1 - int(a[0])) +    m = (a + c).find(c) +    n = (b + c).find(c) +    print((len(s) // 2 + min(m, n)))