s = eval(input())



n = len(s)

ans = n

for i, (c1, c2) in enumerate(zip(s[:-1], s[1:])):

    if c1 == c2:

        continue

    ans = min(ans, max(i + 1, n - i - 1))



print(ans)

s = eval(input())

n = len(s)

k = 0

tmp = set()

while k * 2 < n and len(tmp) < 2:

    tmp.add(s[n // 2 + k])

    tmp.add(s[(n - 1) // 2 - k])

    k += 1

print((n // 2 + k - (len(tmp) == 2)))
s = eval(input())
n = len(s)
ans = n
for i, (c1, c2) in enumerate(zip(s[:-1], s[1:])):
    if c1 == c2:
        continue
    ans = min(ans, max(i + 1, n - i - 1))
print(ans)

s = eval(input())
n = len(s)
k = 0
tmp = set()
while k * 2 < n and len(tmp) < 2:
    tmp.add(s[n // 2 + k])
    tmp.add(s[(n - 1) // 2 - k])
    k += 1
print((n // 2 + k - (len(tmp) == 2)))

-ans = n -for i, (c1, c2) in enumerate(zip(s[:-1], s[1:])): -    if c1 == c2: -        continue -    ans = min(ans, max(i + 1, n - i - 1)) -print(ans) +k = 0 +tmp = set() +while k * 2 < n and len(tmp) < 2: +    tmp.add(s[n // 2 + k]) +    tmp.add(s[(n - 1) // 2 - k]) +    k += 1 +print((n // 2 + k - (len(tmp) == 2)))