string = input()
# string = "1" * 50000 + "0" * 50000
start_length = len(string)


while len(string) > 0:
  if "10" in string or "01" in string:
    string = string.replace("1111111100000000", "")
    string = string.replace("11111110000000", "")
    string = string.replace("111111000000", "")
    string = string.replace("1111100000", "")
    string = string.replace("11110000", "")
    string = string.replace("111000", "")
    string = string.replace("1100", "")
    string = string.replace("0000000011111111", "")
    string = string.replace("00000001111111", "")
    string = string.replace("0000011111", "")
    string = string.replace("00001111", "")
    string = string.replace("000111", "")
    string = string.replace("0011", "")
    string = string.replace("10", "")
    string = string.replace("01", "")
  else:
    break

print(start_length - len(string))
