s = input()
length_s = len(s)
list_s = list()
for i in range(length_s):
    list_s.append(s[:1])
    s = s[1:]
for i in range(length_s):
    length = len(list_s)
    if (length < 2):
        break
    for j in range(length - 1):
        if(list_s[j] != list_s[j+1]):
            del list_s[j:j+2]
            break;
print(length_s - len(list_s))
