import sys
S = input()
S_list = list(S)
flag = 1
S_pick = []

if len(S) < 2:
    print(0)
    sys.exit()

while flag:
    if len(S_list) == 0:
        break
    tmp = S_list[0]
    count = 0
    for i in range(1, len(S_list)):
        if S_list[i] == tmp and i == len(S_list)-1:
            break
            
        elif S_list[i] == tmp:
            tmp = S_list[i]
        else:
            S_pick.append(i-1)
            S_pick.append(i)
            tmp = S_list[i+1]
    for i in range(len(S_pick)-1, -1, -1):
        S_list.pop(S_pick[i])
    if len(S_pick) == 0:
        flag = 0
    S_pick = []
    
print(len(S)-len(S_list))