list = []

cnt = 0



for i in eval(input()):

    if list:

        if list[-1] != i:

            list.pop(-1)

            cnt += 2

        else:

            list.append(i)

    else:

        list.append(i)



print(cnt)
list = []

cnt = 0

for i in eval(input()):

    if not list:

        list.append(i)

    elif list[-1] != i:

        list.pop(-1)

        cnt += 2

    else:

        list.append(i)



print(cnt)

list = []
cnt = 0
for i in eval(input()):
    if list:
        if list[-1] != i:
            list.pop(-1)
            cnt += 2
        else:
            list.append(i)
    else:
        list.append(i)
print(cnt)

list = []
cnt = 0
for i in eval(input()):
    if not list:
        list.append(i)
    elif list[-1] != i:
        list.pop(-1)
        cnt += 2
    else:
        list.append(i)
print(cnt)

-    if list: -        if list[-1] != i: -            list.pop(-1) -            cnt += 2 -        else: -            list.append(i) +    if not list: +        list.append(i) +    elif list[-1] != i: +        list.pop(-1) +        cnt += 2