import copy
s = list(input())

def check01(s):
    if len(s) > 1:
        for i in range(len(s)-1):
            if s[i] != s[i+1]:
                del s[i:i+2]
                return check01(s)
    return s
s2 = copy.deepcopy(s)
s2 = check01(s2)
print(len(s) - len(s2))

