# [a,b] - [a,b) = {b} なので、端の方は自由。

# 中央が単色であるかを確認すればよい。



import numpy as np

arr = np.array([int(x) for x in eval(input())])

arr_c = arr.cumsum()



N = arr.size



answer = 0



for K in range(N,0,-1):

  left = N-K

  right = K-1

  # [left,right]が単色であればよい

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

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



import itertools



S = [int(x) - ord('0') for x in read().rstrip()]



N = len(S)



Scum = list(itertools.accumulate(S))



def test(x):

    if x + x <= N:

        return True

    L = N - x

    R = x

    cnt = Scum[R-1] - Scum[L] + S[L]

    return cnt in [0,R-L]



left = 0 # True

right = N + 1 # False

while left + 1 < right:

    x = (left + right) // 2

    if test(x):

        left = x

    else:

        right = x

answer = left

print(answer)
# [a,b] - [a,b) = {b} なので、端の方は自由。
# 中央が単色であるかを確認すればよい。
import numpy as np

arr = np.array([int(x) for x in eval(input())])
arr_c = arr.cumsum()
N = arr.size
answer = 0
for K in range(N, 0, -1):
    left = N - K
    right = K - 1
    # [left,right]が単色であればよい
    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)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools

S = [int(x) - ord("0") for x in read().rstrip()]
N = len(S)
Scum = list(itertools.accumulate(S))


def test(x):
    if x + x <= N:
        return True
    L = N - x
    R = x
    cnt = Scum[R - 1] - Scum[L] + S[L]
    return cnt in [0, R - L]


left = 0  # True
right = N + 1  # False
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        left = x
    else:
        right = x
answer = left
print(answer)

-# [a,b] - [a,b) = {b} なので、端の方は自由。 -# 中央が単色であるかを確認すればよい。 -import numpy as np +import sys -arr = np.array([int(x) for x in eval(input())]) -arr_c = arr.cumsum() -N = arr.size -answer = 0 -for K in range(N, 0, -1): -    left = N - K -    right = K - 1 -    # [left,right]が単色であればよい -    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 +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +import itertools + +S = [int(x) - ord("0") for x in read().rstrip()] +N = len(S) +Scum = list(itertools.accumulate(S)) + + +def test(x): +    if x + x <= N: +        return True +    L = N - x +    R = x +    cnt = Scum[R - 1] - Scum[L] + S[L] +    return cnt in [0, R - L] + + +left = 0  # True +right = N + 1  # False +while left + 1 < right: +    x = (left + right) // 2 +    if test(x): +        left = x +    else: +        right = x +answer = left