s = input()
sl = len(s)
s = list(s)
while True:
  flag = False
  for i in range(len(s)-1):
    if i+1 > len(s)-1 : break
    if s[i] != s[i+1]:
      s.pop(i+1)
      s.pop(i)
      flag = True
  else:
    if not flag:
      break
print(sl - len(s))