S = eval(input())

l = len(S)

i = 0

if l%2:

    c = S[l//2]

    for i in range(1,l//2+1):

        if S[l//2-i] != c or S[l//2 + i] != c:

            break

    else:

        i += 1

    print((l//2+i))

else:

    c = S[l//2]

    for i in range(l//2):

        if S[l//2-1-i] != c or S[l//2 + i] != c:

            break

    else:

        i += 1

        pass

    print((l//2 + i))
S = eval(input())

N = len(S)



def f(k):

    s = S[-k:k]

    if s == "":return False

    return s.count(s[0])!=len(s)



def binary_search(l,r,func):

    if func(l):return l-1

    if not func(r):return r

    while l+1<r:

        i = (l+r)//2

        if func(i):

            r = i

        else:

            l = i

    return l



print((binary_search(0,N,f)))
S = eval(input())
l = len(S)
i = 0
if l % 2:
    c = S[l // 2]
    for i in range(1, l // 2 + 1):
        if S[l // 2 - i] != c or S[l // 2 + i] != c:
            break
    else:
        i += 1
    print((l // 2 + i))
else:
    c = S[l // 2]
    for i in range(l // 2):
        if S[l // 2 - 1 - i] != c or S[l // 2 + i] != c:
            break
    else:
        i += 1
        pass
    print((l // 2 + i))

S = eval(input())
N = len(S)


def f(k):
    s = S[-k:k]
    if s == "":
        return False
    return s.count(s[0]) != len(s)


def binary_search(l, r, func):
    if func(l):
        return l - 1
    if not func(r):
        return r
    while l + 1 < r:
        i = (l + r) // 2
        if func(i):
            r = i
        else:
            l = i
    return l


print((binary_search(0, N, f)))

-l = len(S) -i = 0 -if l % 2: -    c = S[l // 2] -    for i in range(1, l // 2 + 1): -        if S[l // 2 - i] != c or S[l // 2 + i] != c: -            break -    else: -        i += 1 -    print((l // 2 + i)) -else: -    c = S[l // 2] -    for i in range(l // 2): -        if S[l // 2 - 1 - i] != c or S[l // 2 + i] != c: -            break -    else: -        i += 1 -        pass -    print((l // 2 + i)) +N = len(S) + + +def f(k): +    s = S[-k:k] +    if s == "": +        return False +    return s.count(s[0]) != len(s) + + +def binary_search(l, r, func): +    if func(l): +        return l - 1 +    if not func(r): +        return r +    while l + 1 < r: +        i = (l + r) // 2 +        if func(i): +            r = i +        else: +            l = i +    return l + + +print((binary_search(0, N, f)))