import sys, itertools
s = sys.stdin.readline().strip()
l = n1 = len(s)
while True:
    n = l
    skip = False
    _s = ""
    for i, j in itertools.zip_longest(s[:], s[1:]):
        if skip:
            skip = False
            continue
        if i != j and j != None:
            skip = True
        else:
            _s += i
    s = _s
    l = len(s)
    if l != 0 and n != l:
        continue
    else:
        break
print(n1 - len(s))