import sys
from collections import deque

input = sys.stdin.readline


def main():
    S = input().rstrip()

    stack = deque()
    ans = 0
    for s in S:
        if len(stack) == 0:
            stack.append(s)
        else:
            if stack[-1] != s:
                stack.pop()
                ans += 2
            else:
                stack.append(s)

    print(ans)


if __name__ == "__main__":
    main() import sys sys from collections import deque input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    S = input().rstrip()

    stack = deque()
    ans = 0
    for s in S:
        if len(stack) == 0:
            stack.append(s)
        else:
            if stack[-1] != s:
                stack.pop()
                ans += 2
            else:
                stack.append(s)

    print(ans) main S = input().rstrip() S input().rstrip() ().rstrip () input rstrip stack = deque() stack deque() deque ans = 0 ans 0 for s in S:
        if len(stack) == 0:
            stack.append(s)
        else:
            if stack[-1] != s:
                stack.pop()
                ans += 2
            else:
                stack.append(s)

     s S if len(stack) == 0:
            stack.append(s)
        else:
            if stack[-1] != s:
                stack.pop()
                ans += 2
            else:
                stack.append(s)

     len(stack) == 0 len(stack) len stack 0 stack.append(s) stack.append stack append s if stack[-1] != s:
                stack.pop()
                ans += 2
            else:
                stack.append(s)

     stack[-1] != s stack[-1] stack -1 s stack.pop() stack.pop stack pop ans += 2 ans 2 stack.append(s) stack.append stack append s print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    S = input().rstrip()

    stack = deque()
    ans = 0
    for s in S:
        if len(stack) == 0:
            stack.append(s)
        else:
            if stack[-1] != s:
                stack.pop()
                ans += 2
            else:
                stack.append(s)

    print(ans) def main():
    S = input().rstrip()

    stack = deque()
    ans = 0
    for s in S:
        if len(stack) == 0:
            stack.append(s)
        else:
            if stack[-1] != s:
                stack.pop()
                ans += 2
            else:
                stack.append(s)

    print(ans) main input = sys.stdin.readline sys.stdin.readline input
import sys
from collections import deque

input = sys.stdin.readline


def main():
    S = input().rstrip()

    stack = deque()
    ans = 0
    for s in S:
        if len(stack) == 0:
            stack.append(s)
        else:
            if stack[-1] != s:
                stack.pop()
                ans += 2
            else:
                stack.append(s)

    print(ans)


if __name__ == "__main__":
    main()
