s = list(input())
n = n0 = len(s)
nn = 0
while n > 1 and n != nn:
  n = len(s)
  for i in range(n-1, 1, -1):
    if s[i] != s[i-1]:
      s.pop(i)
      s.pop(i-1)
      i -= 1
  nn = len(s)
print(n0 - len(nn))