s = input()

prev = []
for i in range(len(s)):
    prev.append(s[i])
while True:
    result = []
    i = 0
    while i < (len(prev)-1):
        if prev[i] != prev[i+1]:
            i += 2
        else:
            result.append(prev[i])
            i += 1
    if i == (len(prev) - 1):
        result.append(prev[-1])
    if prev == result:
        break
    prev = result
print(len(s) - len(result))
