import sys
input = sys.stdin.readline
S=input()
N=int(len(S))
for _ in range(N):
    A=S
    S=S.replace("0110","")
    S=S.replace("0101","")
    S=S.replace("10","")
    S=S.replace("01","")
    if A==S:
        break
print(N-int(len(S)))