import sys

def f(A, c):
  n = len(A)
  B = []
  for i in range(len(A) -1):
    if A[i] != A[i+1]:
      c += 2
      B += A[i+2:]
      break
    else:
      B.append(A[i])
  if len(B) == n:
    return c
  else:
    return f(B, c)


def main():
  input = sys.stdin.readline
  S = [int(c) for c in input().strip()]
  ans = f(S, 0)
  print(ans)


if __name__ == '__main__':
  main()