import sys
input = sys.stdin.readline
import re
def print_ans(S):
    """Test Case
    >>> print_ans("0011")
    4
    >>> print_ans("11011010001011")
    12
    >>> print_ans("0")
    0
    """
    flg = True
    ans = 0
    while flg:
        tmp = re.sub(r"01|10", "", S)
        if len(tmp) == len(S):
            flg = False
            break
        else:
            ans += len(S) - len(tmp)
            S = tmp
    print(ans)
        


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)
