S = eval(input())

T = len(S)

for i in range(len(S)-1):

    if S[i] != S[i+1]:

        K = max(i+1, len(S)-i-1)

        T = min(T, K)



print(T)
S = eval(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)

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

S = eval(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)

-T = len(S) -for i in range(len(S) - 1): -    if S[i] != S[i + 1]: -        K = max(i + 1, len(S) - i - 1) -        T = min(T, K) -print(T) +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)