import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

s = input()
n = len(s)
last = []
ans = 0
i = 0
last = []
while i<n:
    if last and s[i]!=last[-1]:
        ans += 2
        last.pop()
        i += 1
    else:
        last.append(s[i])
        i += 1
print(ans) import sys sys input = lambda : sys.stdin.readline().rstrip() input lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(max(1000, 10**9)) sys.setrecursionlimit sys setrecursionlimit max(1000, 10**9) max 1000 10**9 10 9 write = lambda x: sys.stdout.write(x+"\n") write lambda x: sys.stdout.write(x+"\n") sys.stdout.write(x+"\n") sys.stdout.write sys.stdout sys stdout write x+"\n" x "\n" x s = input() s input() input n = len(s) n len(s) len s last = [] last [] ans = 0 ans 0 i = 0 i 0 last = [] last [] while i<n:
    if last and s[i]!=last[-1]:
        ans += 2
        last.pop()
        i += 1
    else:
        last.append(s[i])
        i += 1 i<n i n if last and s[i]!=last[-1]:
        ans += 2
        last.pop()
        i += 1
    else:
        last.append(s[i])
        i += 1 last and s[i]!=last[-1] last s[i]!=last[-1] s[i] s i last[-1] last -1 ans += 2 ans 2 last.pop() last.pop last pop i += 1 i 1 last.append(s[i]) last.append last append s[i] s i i += 1 i 1 print(ans) print ans input = lambda : sys.stdin.readline().rstrip() lambda : sys.stdin.readline().rstrip() input write = lambda x: sys.stdout.write(x+"\n") lambda x: sys.stdout.write(x+"\n") write last = [] [] last i += 1 1 i n = len(s) len(s) n ans = 0 0 ans i = 0 0 i ans += 2 2 ans last = [] [] last s = input() input() s i += 1 1 i
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

s = input()
n = len(s)
last = []
ans = 0
i = 0
last = []
while i<n:
    if last and s[i]!=last[-1]:
        ans += 2
        last.pop()
        i += 1
    else:
        last.append(s[i])
        i += 1
print(ans)