N = raw_input()
S = [] 
for i in range(0,len(N)):
  S.append(int(N[i]))
i = 0
while i<=len(S)-2:
  delete = []
  if S[i] != S[i+1]:
    delete.append(i)
    delete.append(i+1)
    i = i + 2
  else:
    i = i + 1
  if i>=len(S)-2:
    if len(delete) != 0:
      delete.reverse()
      for i in delete:
        S.pop(i)
      i = 0
      delete = []
    else:
      break
  if len(S) == 0:
    break
print len(N) - len(S)