S = list(input())
remove = [False] * len(S)

count = 0
is_continue = False

while True:
  is_continue = False
  remove = [False] * len(S)
  for i in range(len(S) - 2):
    if S[i] != S[i+1]:
      remove[i] = True
      remove[i+1] = True
      count += 2
      i += 1
      is_continue = True

  if is_continue == False:
    if len(S) >= 2:
      if S[0] != S[1]:
        S.pop(0)
        S.pop(0)
        count += 2
    print(count)
    exit()
      
  tmp = []
  for i in range(len(S)):
    if remove[i] == False:
      tmp.append(S[i])

  S = tmp
  print(S)