from collections import deque

S = input()

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

print(cnt) from collections import deque S = input() S input() input d = deque() d deque() deque cnt = 0 cnt 0 for s in S:
    if d:
        if d[-1] != s:
            d.pop()
            cnt += 2
        else:
            d.append(s)
    else:
        d.append(s) s S if d:
        if d[-1] != s:
            d.pop()
            cnt += 2
        else:
            d.append(s)
    else:
        d.append(s) d if d[-1] != s:
            d.pop()
            cnt += 2
        else:
            d.append(s)
     d[-1] != s d[-1] d -1 s d.pop() d.pop d pop cnt += 2 cnt 2 d.append(s) d.append d append s d.append(s) d.append d append s print(cnt) print cnt cnt = 0 0 cnt d = deque() deque() d S = input() input() S cnt += 2 2 cnt
from collections import deque

S = input()

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

print(cnt)
