s = list(input())
num_s = len(s)

while True:
    new_s = []
    len_s = len(s)
    while s:
        if len(s)==1:
            new_s.append(s[0])
            break
        x=s.pop(0)
        if s[0]!=x:
            y=s.pop(0)
        else:
            new_s.append(x)
    
    s = new_s
    if len(new_s)==len_s:
        print(num_s-len_s)
        break

