s = input()
curr_starter = s[0]
curr_length = 1
max_unravel = 0
i = 1
while i < len(s):
  start_i = i
  curr_unravel = 0
  while i < len(s) and (s[i] != s[i-1] or (i != len(s)-1 and s[i] != s[i+1])):
    i += 1
    max_unravel = max(max_unravel, 1)
    curr_unravel = 1
  while i < len(s) and curr_length > 0 and s[i] != curr_starter and (i == len(s)-1 or s[i] == s[i+1]):
    i += 1
    curr_length -= 1
    curr_unravel += 1
  max_unravel = max(max_unravel, curr_unravel)
  if i == len(s):
    continue
  if curr_length <= 0:
    if (i == len(s)-1 or s[i] == s[i+1]):
      curr_starter = s[i]
      curr_length = 1
    else:
      curr_starter = curr_length
      curr_length = 0
  elif s[i] == curr_starter and (i == len(s)-1 or s[i] == s[i+1]):
    curr_length += 1

  if start_i == i:
    i += 1

print(max_unravel)
