S = list(input())
size = len(S)
to_remove = []
last_size = len(S)
while True:
    i = 0
    while i < len(S)-1:
        if S[i] != S[i+1]:
            to_remove.append(i)
            to_remove.append(i+1)
            i+=1
        i+=1
    to_remove.reverse()
    for t in to_remove:
        del S[t]
    to_remove = []
    if last_size == len(S) or len(S) == 0:
        break
    else:
        last_size = len(S)
print(size-len(S))