S = input().strip()

def check(l):
  for i in range(len(l)-1):
    if l[i] == l[i+1]:
      return False
  return True

# 一番最後だけ分割する
def hoge(l):
  next_stack = []
  for i in range(1, len(l[-1])):
    next_list = l[:-1] + [l[-1][:i], l[-1][i:]]
    if check(next_list):
      next_stack.append(next_list)
  return next_stack
      
stack = [[S]]
max_len = 1
while True:
  if len(stack) == 0:
    break
  now = stack.pop(0)
  if len(now)+len(now[-1])-2 < max_len:
    continue
  #print('----------')
  #print(now)
  #print(hoge(now))
  max_len = max(max_len, len(now))
  stack += hoge(now)
  
print(max_len)