S = input()

def operate_one(S):
  S = list(S)
  c = 0
  for i in range(len(S) - 1):
    if S[i] != S[i+1] and S[i] != "_":
      c += 2
      S[i] = "_"
      S[i+1] = "_"
  return "".join(S).replace("_",""),c

res = 0
while True:
  S_prev = S
  S,c = operate_one(S)
  res += c
  if S_prev == S:
    break
    
print(res)