import copy
S = list(input())
counter = 0
while(True):
    idxs = []
    flag = 0
    
    for i in range(len(S)-1):
        if flag == 1:
            flag = 0
            continue
        if S[i] != S[i+1]:
            idxs.append(i)
            idxs.append(i+1)
            flag = 1
    
    Scopy = []
    for i in range(len(S)):
        if i not in idxs:
            Scopy.append(S[i])
    S = copy.copy(Scopy)
    counter += len(idxs)
    #print(len(idxs))

    if len(idxs) == 0:
        break

print(counter)