S = input()
N = len(str(S))
cubes = [int(i) for i in list(S)]

first_comb = [0]
second_comb = [0]
while len(first_comb) > 0 or len(second_comb) > 0:
  length = len(cubes)
  first_comb = []
  second_comb = []
  for i in range(length - 1):
    if (cubes[i] == 0 and cubes[i + 1] == 1) or (cubes[i] == 1 and cubes[i + 1] == 0):
      if i + 2 <= length - 1 and i - 1 >= 0:
        if (cubes[i + 2] == 0 and cubes[i - 1] == 1) or (cubes[i + 2] == 1 and cubes[i - 1] == 0):
          first_comb.append([i, i + 1])
        else: 
          second_comb.append([i, i + 1])
      else: 
        second_comb.append([i, i + 1])

  if len(first_comb) > 0:
    cubes.pop(first_comb[0][0])
    cubes.pop(first_comb[0][1] - 1)
  elif len(second_comb) > 0:
    cubes.pop(second_comb[0][0])
    cubes.pop(second_comb[0][1] - 1)

print(N - len(cubes))

