def f(s):
    _s = s + '*'
    i = 0
    ans = 0
    while True:
        if _s[i] == '*':
            return _s[:-1], ans
        elif _s[i+1] == '*':
            i += 1
        elif _s[i] == _s[i+1]:
            i += 1
        else:
            ans += 2
            if i == 0:
                _s = _s[i+2:]
            else:
                _s = _s[:i] + _s[i+2:]


s = input()
ans = 0
while True:
    s, _ans = f(s)
    if _ans != 0:
        ans += _ans
    else:
        break
print(ans)