def is_ok(k):

    imos = [0] * (len(s) + 2)



    for i, x in enumerate(s, 1):

        imos[i] ^= imos[i - 1]

        if i <= len(s) - (k - 1):

            # 連続kの区間をi起点に取ることができる

            if x ^ imos[i - 1]:

                imos[i] ^= 1

                imos[i + k] ^= 1

        else:

            if x ^ imos[i - 1]:

                return i > k

    return True





def binary_search():

    ok = 1

    ng = len(s) + 1

    while abs(ng - ok) > 1:

        mid = (ng + ok) // 2

        if is_ok(mid):

            ok = mid

        else:

            ng = mid

    return ok





s = tuple(map(int, eval(input())))

print((binary_search()))



# Kで達成できるとき、K未満で達成できる

# TTTTFFF

#    ^

#    K

# 二分探索する

s = tuple(map(int, eval(input())))

n = len(s)



ret = n

p = s[0]

for i, x in enumerate(s):

    if x != p:

        ret = min(ret, max(i, n - i))

    p = x

print(ret)

def is_ok(k):
    imos = [0] * (len(s) + 2)
    for i, x in enumerate(s, 1):
        imos[i] ^= imos[i - 1]
        if i <= len(s) - (k - 1):
            # 連続kの区間をi起点に取ることができる
            if x ^ imos[i - 1]:
                imos[i] ^= 1
                imos[i + k] ^= 1
        else:
            if x ^ imos[i - 1]:
                return i > k
    return True


def binary_search():
    ok = 1
    ng = len(s) + 1
    while abs(ng - ok) > 1:
        mid = (ng + ok) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


s = tuple(map(int, eval(input())))
print((binary_search()))
# Kで達成できるとき、K未満で達成できる
# TTTTFFF
#    ^
#    K
# 二分探索する

s = tuple(map(int, eval(input())))
n = len(s)
ret = n
p = s[0]
for i, x in enumerate(s):
    if x != p:
        ret = min(ret, max(i, n - i))
    p = x
print(ret)

-def is_ok(k): -    imos = [0] * (len(s) + 2) -    for i, x in enumerate(s, 1): -        imos[i] ^= imos[i - 1] -        if i <= len(s) - (k - 1): -            # 連続kの区間をi起点に取ることができる -            if x ^ imos[i - 1]: -                imos[i] ^= 1 -                imos[i + k] ^= 1 -        else: -            if x ^ imos[i - 1]: -                return i > k -    return True - - -def binary_search(): -    ok = 1 -    ng = len(s) + 1 -    while abs(ng - ok) > 1: -        mid = (ng + ok) // 2 -        if is_ok(mid): -            ok = mid -        else: -            ng = mid -    return ok - - -print((binary_search())) -# Kで達成できるとき、K未満で達成できる -# TTTTFFF -#    ^ -#    K -# 二分探索する +n = len(s) +ret = n +p = s[0] +for i, x in enumerate(s): +    if x != p: +        ret = min(ret, max(i, n - i)) +    p = x +print(ret)