import sys

cubes = list(input()) # 入力受付
stack = []
count = 0

for cube in cubes:
    if not stack:
        stack.append(cube)
    elif stack[-1] != cube:
        count += 2
        stack.pop()
    else:
        stack.append(cube)
print(count) import sys sys cubes = list(input()) cubes list(input()) list input() input stack = [] stack [] count = 0 count 0 for cube in cubes:
    if not stack:
        stack.append(cube)
    elif stack[-1] != cube:
        count += 2
        stack.pop()
    else:
        stack.append(cube) cube cubes if not stack:
        stack.append(cube)
    elif stack[-1] != cube:
        count += 2
        stack.pop()
    else:
        stack.append(cube) not stack stack stack.append(cube) stack.append stack append cube elif stack[-1] != cube:
        count += 2
        stack.pop()
     stack[-1] != cube stack[-1] stack -1 cube count += 2 count 2 stack.pop() stack.pop stack pop stack.append(cube) stack.append stack append cube print(count) print count cubes = list(input()) list(input()) cubes stack = [] [] stack count += 2 2 count count = 0 0 count
import sys

cubes = list(input()) # 入力受付
stack = []
count = 0

for cube in cubes:
    if not stack:
        stack.append(cube)
    elif stack[-1] != cube:
        count += 2
        stack.pop()
    else:
        stack.append(cube)
print(count)
