#!/usr/bin/env python3
import sys


def solve(S: str):
    n = len(S)
    while True:
        l = len(S)
        for i in range(len(S) - 1):
            if S[i] != S[i + 1]:
                S = S[:i] + S[i + 2:]
                break
        if l == len(S):
            break
    print(n - len(S))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()
