A = eval(input())



len0 = lenA = len(A) 

while(True):

    A = A.replace("10","").replace("01","").replace("1"*1000 + "0"*1000,"").replace("0"*1000 + "1"*1000,"")

    if lenA == len(A):

        break

    lenA = len(A)

print((len0 - lenA))

A = eval(input())



C0 = A.count('0')

C1 = A.count('1')

print((2*min(C0,C1)))

    

  
A = eval(input())
len0 = lenA = len(A)
while True:
    A = (
        A.replace("10", "")
        .replace("01", "")
        .replace("1" * 1000 + "0" * 1000, "")
        .replace("0" * 1000 + "1" * 1000, "")
    )
    if lenA == len(A):
        break
    lenA = len(A)
print((len0 - lenA))

A = eval(input())
C0 = A.count("0")
C1 = A.count("1")
print((2 * min(C0, C1)))

-len0 = lenA = len(A) -while True: -    A = ( -        A.replace("10", "") -        .replace("01", "") -        .replace("1" * 1000 + "0" * 1000, "") -        .replace("0" * 1000 + "1" * 1000, "") -    ) -    if lenA == len(A): -        break -    lenA = len(A) -print((len0 - lenA)) +C0 = A.count("0") +C1 = A.count("1") +print((2 * min(C0, C1)))