s = raw_input()
arr = [c for c in s]
done = False
while not done:
    exist01 = False
    new_arr = []
    i = 0
    while i < len(arr)-1:
        if arr[i] != arr[i+1]:
            i += 2
            exist01 = True
        else:
            new_arr.append(arr[i])
            i += 1
    if i < len(arr):
        new_arr.append(arr[i])
    arr = new_arr
    if not exist01:
        done = True
print len(s)-len(arr)