S = input()
count = 0
while True:
    flag = []
    S = list(S)
    for i in range(len(S)):
        if i == 0:
            pre_s = S[i]
            flag.append(0)
        else:
            if pre_s != S[i] and flag[i-1] == 0:
                flag.append(1)
                flag[i-1] = 1
                pre_s = S[i]
                S[i-1] = "a"
                S[i] = "a"
            else:
                flag.append(0)
                pre_s = S[i]
            
    if sum(flag) == 0:
        break
    else:
        count += sum(flag)

    S = "".join(S).replace("a", "")
            
print(count)