S=raw_input()
A=[s for s in S]

while True:
    A_new=[]
    i=0
    while i<len(A):
        if i<len(A)-1:
            if A[i]!=A[i+1]:
                i+=2
            else:
                A_new.append(A[i])
                i+=1
        else:
            A_new.append(A[i])
            i+=1
    if A==A_new:
        break
    else:
        A=A_new[:]
print len(S)-len(A)