n_list = list(input())
n_len_o = len(n_list)
#print(n_list)
a = 0
while(1):
  flag = "ng"
  n_len = len(n_list)
  for i in range(a,n_len-1):
    if n_list[i] != n_list[i+1]:
      n_list.pop(i)
      n_list.pop(i)
      if a != 0:
        a = i - 1
      else:
        a = 0
      flag = "ok"
      break
  if flag == "ng":
    break
#print(n_list)
print(n_len_o-len(n_list))