cubes= list(input())
re= True
start= len(cubes)
while re:
  same=0
  if len(cubes) == 1:
    break
  for i in range(len(cubes)-1):
    if cubes[i] != cubes[i+1]:
      del cubes[i]
      del cubes[i]
      i -= 1
      max= len(cubes)-2
      break
    else:
      same+= 1
  if same == len(cubes)-1:
    break
print(start-len(cubes))