def D(i, S):
  if i < len(S):
    if S[-1*i] != S[-1*(i+1)]:
      del S[-1*(i+1)]
      del S[-1*i]
      if len(S) == 0:
        return S
      else:
      	return D(min(i-1,1),S)
    return D(i+1,S)
  else:
    return S
  
S = list(input())
SS = S.copy()
S_after = D(1, SS)
print(len(S) - len(S_after))