def algo(s):
  if len(s) == 1:
    return 0
  elif len(s) == 2:
    if s[0] != s[1]:
      return 2
    else:
      return 0
  else:
    tmp = ""
    for i in range(1, len(s)-1):
      if s[i] != s[i+1]:
        tmp += s[0:i] + s[i+2:]
        break
    return 2 + algo(tmp)
    
x = input()
ans = algo(x)
print(ans)