S = input()
N = len(S)
while True:
  temp_S = S
  temp_S = temp_S.replace('0011', '').replace('1010', '')
  temp_S = temp_S.replace('0101', '').replace('1100', '')
  temp_S = temp_S.replace('01', '').replace('10', '')
  if temp_S == S:
    break
  S = temp_S

print(N - len(S))