import sys
input = sys.stdin.readline
S=list(input().strip())

flag=True
cnt=0
i=0
f=[]
if len(S) != 1:
    while flag:
        if S[i] != S[i+1]:
            f.append(i)
            f.append(i+1)
            i+=2
        else:
            i+=1
        if i>=len(S)-1:
            cnt+=len(f)
            f.reverse()
            for k in f:
                S.pop(k)
            f=[]
            if '1' not in S or '0' not in S:
                break
            i=0
print(cnt)