s = list(input())
n1 = len(s)
while True:
    n = len(s)
    _s = []
    skip = False
    for i in range(n):
        if skip:
            skip = False
            continue
        if i == n-1 or s[i] == s[i+1]:
            _s += s[i]
        else:
            skip = True
    s = _s
    if len(s) == 0 or n == len(s):
        break
print(n1 - n)