import re
s=input()
m=0
for i in range(len(s)//2):
  dst = re.sub(r'01|10', "", s)
  dst = re.sub(r'00000000000000000000001111111111111111111111|11111111111111111111110000000000000000000000', "", dst)
  if dst == s:
    break
  m += len(s) - len(dst)
  s=dst
print(m)