import copy

s = input()
s_sub = copy.deepcopy(s)
# 
tar1 = "01"
tar2 = "10"
# tar3 = ["1010","1001","0101","0110"]

while((tar1 in s )or(tar2 in s)):
    
    
    # for i in range(4):
    #     if tar3[i] in s:
    #         s = s.replace(tar3[i],"")
    

    if tar1 in s:
        s = s.replace(tar1,"",1)
    if tar2 in s:
        s = s.replace(tar2,"",1)



print(len(s_sub)-len(s))