S=input().strip()
N=len(S)

a=[0 if x == '0' else 1 for x in S]

while True:
    v = 0
    p = -1
    b = []
    for i in a:
        if p >= 0:
            if p == 0 or p == 1:
                if i == 0 or i == 1:
                    if p != i:
                        p = -1
                        v += 1
                        continue
            b.append(p)
        p = i
    if p >= 0:
        b.append(p)
    if v == 0:
        print(N - len(a))
        break
    a = b

