s = list(str(input()))
ans = 0
drop = False
for r in range(1, len(s)):
    if drop == False:
        l = r - 1
        if s[l] != -1 and s[l] != s[r]:
            ans += 2
            s[l], s[r] = -1, -1
            drop = True
    elif drop == True:
        while l >= 0 and s[l] == -1:
            l -= 1
        if l == -1 or s[l] == s[r]:
            drop = False
            continue
        if s[l] != s[r]:
            ans += 2
            s[l], s[r] = -1, -1
print(ans)