s = list(input())
t = []
p = 0
flg = True

while flg:
    flg = False
    j = 0
    for i in range(len(s)):
        if s[j] == s[j+1]:
            t.append(s[j])
            j += 1
        else:
            p += 2
            j += 2
        if j >= len(s) - 1:
            if j == len(s) - 1:
                t.append(s[j])
                break
            else:
                break
    if len(t) == len(s) or len(t) == 0:
        pass
    else:
        s = t
        t.clear()
        flg = True

print(p)