s = input()
l_s = []
for i in range(len(s)):
    l_s.append(s[i])

b = True
if len(l_s) == 1:
    print(0)
    exit()

while len(l_s) > 0 and b == True:
    for i in range(len(l_s) - 1):
        if l_s[i] != l_s[i+1]:
            del l_s[i:i+2]
            break
        if i == len(l_s) - 2:
            b = False

ans = len(s) - len(l_s)
print(ans)