import re
s=input()
m=0
s1 = re.compile(r'01|10')
l1 = re.compile(r'000111|111000|00001111|11110000|0000011111|1111100000')
for i in range(len(s)//2):
  dst = re.sub(s1, "", s)
  dst = re.sub(l1, "", dst)
  if dst == s:
    break
  m += len(s) - len(dst)
  s=dst
print(m)