#!/usr/bin/env python3
s = input()
c = 0
while True:
    ns = ""
    p = ""
    f = [1] * len(s)
    for i in range(len(s)):
        if f[i] > 0:
            if i == len(s)-1:
                ns += s[i]
            elif s[i] != s[i + 1]:
                c += 2
                f[i + 1] = 0
            else:
                ns += s[i]
    if ns == s:
        break
    s = ns
print(c)
