stack = []
top = -1

def push(x):
    global stack
    global top

    top += 1
    stack.append(x)

def pop2():
    global top
    global stack

    top -= 1
    stack.pop()

def main():
    global top
    global stack

    S = input()
    ans = 0

    for i in range(len(S)):
        if i == 0:
            push(S[0])
            continue

        push(S[i])
        if stack[top] != stack[top-1]:
            pop2()
            pop2()
            ans += 2
            continue

    return ans

print(main()) stack = [] stack [] top = -1 top -1 def push(x):
    global stack
    global top

    top += 1
    stack.append(x) push global stack global top top += 1 top 1 stack.append(x) stack.append stack append x x x def pop2():
    global top
    global stack

    top -= 1
    stack.pop() pop2 global top global stack top -= 1 top 1 stack.pop() stack.pop stack pop def main():
    global top
    global stack

    S = input()
    ans = 0

    for i in range(len(S)):
        if i == 0:
            push(S[0])
            continue

        push(S[i])
        if stack[top] != stack[top-1]:
            pop2()
            pop2()
            ans += 2
            continue

    return ans main global top global stack S = input() S input() input ans = 0 ans 0 for i in range(len(S)):
        if i == 0:
            push(S[0])
            continue

        push(S[i])
        if stack[top] != stack[top-1]:
            pop2()
            pop2()
            ans += 2
            continue

     i range(len(S)) range len(S) len S if i == 0:
            push(S[0])
            continue

         i == 0 i 0 push(S[0]) push S[0] S 0 continue push(S[i]) push S[i] S i if stack[top] != stack[top-1]:
            pop2()
            pop2()
            ans += 2
            continue

     stack[top] != stack[top-1] stack[top] stack top stack[top-1] stack top-1 top 1 pop2() pop2 pop2() pop2 ans += 2 ans 2 continue return ans ans print(main()) print main() main def main():
    global top
    global stack

    S = input()
    ans = 0

    for i in range(len(S)):
        if i == 0:
            push(S[0])
            continue

        push(S[i])
        if stack[top] != stack[top-1]:
            pop2()
            pop2()
            ans += 2
            continue

    return ans def main():
    global top
    global stack

    S = input()
    ans = 0

    for i in range(len(S)):
        if i == 0:
            push(S[0])
            continue

        push(S[i])
        if stack[top] != stack[top-1]:
            pop2()
            pop2()
            ans += 2
            continue

    return ans main top = -1 -1 top def push(x):
    global stack
    global top

    top += 1
    stack.append(x) def push(x):
    global stack
    global top

    top += 1
    stack.append(x) push def pop2():
    global top
    global stack

    top -= 1
    stack.pop() def pop2():
    global top
    global stack

    top -= 1
    stack.pop() pop2 stack = [] [] stack
stack = []
top = -1

def push(x):
    global stack
    global top

    top += 1
    stack.append(x)

def pop2():
    global top
    global stack

    top -= 1
    stack.pop()

def main():
    global top
    global stack

    S = input()
    ans = 0

    for i in range(len(S)):
        if i == 0:
            push(S[0])
            continue

        push(S[i])
        if stack[top] != stack[top-1]:
            pop2()
            pop2()
            ans += 2
            continue

    return ans

print(main())
