S=input()

N=len(S)

TS=N

for k in range(N-1):

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

		TS=min(TS, max(k+1, N-k-1))



print(TS)
S=input()

N=len(S)

c=len(S)/2





if N%2==1:

	cnt=c+1

	for i in range(1,c+1):

		if S[c-i]==S[c+i]==S[c]:

			cnt+=1

			pass

		else:

			break

else:

	cnt=c

	if S[c]!=S[c-1]:

		print(cnt)

		quit()

	cnt+=1

	for i in range(1,c):

		if S[c+i]==S[c-i-1]==S[c]:

			cnt+=1

		else:

			break



print(cnt)

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

S = input()
N = len(S)
c = len(S) / 2
if N % 2 == 1:
    cnt = c + 1
    for i in range(1, c + 1):
        if S[c - i] == S[c + i] == S[c]:
            cnt += 1
            pass
        else:
            break
else:
    cnt = c
    if S[c] != S[c - 1]:
        print(cnt)
        quit()
    cnt += 1
    for i in range(1, c):
        if S[c + i] == S[c - i - 1] == S[c]:
            cnt += 1
        else:
            break
print(cnt)

-TS = N -for k in range(N - 1): -    if S[k] != S[k + 1]: -        TS = min(TS, max(k + 1, N - k - 1)) -print(TS) +c = len(S) / 2 +if N % 2 == 1: +    cnt = c + 1 +    for i in range(1, c + 1): +        if S[c - i] == S[c + i] == S[c]: +            cnt += 1 +            pass +        else: +            break +else: +    cnt = c +    if S[c] != S[c - 1]: +        print(cnt) +        quit() +    cnt += 1 +    for i in range(1, c): +        if S[c + i] == S[c - i - 1] == S[c]: +            cnt += 1 +        else: +            break +print(cnt)