s = eval(input())

n = len(s)



l = []

tmp = []

i = 0

ans = 0

while i < n-1:

	if s[i] != s[i+1]:

		ans += 1

		num = 2

		while i+num < n:

			if len(l) == 0:

				break

			left = l.pop()

			right = s[i+num]

			if s[left] != right:

				ans += 1

				num += 1

			else:

				l.append(left)

				break

		i += num

	else:

		l.append(i)

		i += 1



print((2*ans))

import collections



s = list(eval(input()))



count = collections.Counter(s)



zero = count['0']

one = count['1']



print((2 * min(zero,one)))

s = eval(input())
n = len(s)
l = []
tmp = []
i = 0
ans = 0
while i < n - 1:
    if s[i] != s[i + 1]:
        ans += 1
        num = 2
        while i + num < n:
            if len(l) == 0:
                break
            left = l.pop()
            right = s[i + num]
            if s[left] != right:
                ans += 1
                num += 1
            else:
                l.append(left)
                break
        i += num
    else:
        l.append(i)
        i += 1
print((2 * ans))

import collections

s = list(eval(input()))
count = collections.Counter(s)
zero = count["0"]
one = count["1"]
print((2 * min(zero, one)))

-s = eval(input()) -n = len(s) -l = [] -tmp = [] -i = 0 -ans = 0 -while i < n - 1: -    if s[i] != s[i + 1]: -        ans += 1 -        num = 2 -        while i + num < n: -            if len(l) == 0: -                break -            left = l.pop() -            right = s[i + num] -            if s[left] != right: -                ans += 1 -                num += 1 -            else: -                l.append(left) -                break -        i += num -    else: -        l.append(i) -        i += 1 -print((2 * ans)) +import collections + +s = list(eval(input())) +count = collections.Counter(s) +zero = count["0"] +one = count["1"] +print((2 * min(zero, one)))