import sys
s = str(input())
p = len(s)
new = []
if p == 1:
    print("0")
    sys.exit()
while True:
    for i in range(len(s)-1):
        if i == len(s) - 2:
            if s[i] != s[i+1]:
                s = s[:i] + s[i+2:]
                print(p-len(s))
                sys.exit()
            else:
                print(p-len(s))
                sys.exit()
        elif s[i] != s[i+1]:
            s = s[:i] + s[i+2:]
            break

        
        