s = list(input())
t = []
p = len(s)
flg = True

while flg:
    flg = False
    i = 0
    while i < len(s):
        if i < len(s)-1:
            if s[i] != s[i+1]:
                i += 2
                flg = True
            else:
                t.append(s[i])
                i += 1
        else:
            t.append(s[i])
            i += 1
    s = list(t)
    t.clear()

print(p - len(s))