s = input()
l = len(s)
dp = [0] * l
st = [0] * (l + 1)
i = 0
for _ in range(l - 1):
    if dp[_]:
        continue
    if s[_] != s[_ + 1]:
        dp[_] = 1
        dp[_ + 1] = 1
    elif i and s[_] != s[st[i]]:
        dp[st[i]] = dp[st[i] + 1] + 1
        i -= 1
    else:
        i += 1
        st[i] = _
if not dp[-1] and i and s[-1] != s[st[i]]:
    dp[st[i]] = dp[st[i] + 1] + 1
print(max(dp))
