import copy
s = list(input())
def check01_2(s, pos):
    p = 0
    if abs(len(s) - pos)  > 2:
        for i in range(pos, len(s), 1):
            if s[i] != s[i+1]:
                del s[i:i+2]
                if i !=0:
                    p = i-1
                return check01_2(s, p)
    return s

s2 = copy.deepcopy(s)
s2 = check01_2(s2, 0)
print(len(s) - len(s2))

