S = input()
N = len(S)

a = 0
while a == 0:
    S = S.replace("0110", "")
    S = S.replace("1001", "")
    S = S.replace("01", "")
    S = S.replace("10", "")
    if "01" in S or "10" in S:
        a = 0
    else:
        a = 1

print(str(N - len(S)))