S = input()
l = len(S)
t = True
nex = 0
while t:
    s = S
    for i in range(len(S)-1):
        if nex == 1:
            nex = 0
            continue
        if S[i:i+2] == '01' or S[i:i+2] == '10':
            s = s[:i] + '--' + s[i+2:]
            nex = 1
    #print('s',s)
    s = s.replace('-','')
    if s == S:
        print(l-len(S))
        exit()
    if len(s) == 0:
        print(l)
        exit()
    S = s