s = input()
tn = len(s)
n = len(s)


while True:
    t = 0
    i = 0
    while i < n - 1:
        if s[i] != s[i+1]:
            s = s[:i] + s[i+2:]
            if t == 0:
                t = 1
            n = len(s)
        else: i += 1
    if t == 0: break

print(tn - n)