import sys
from operator import itemgetter
import collections


def r(s):

    length = len(s)

    flg = True
    while flg:
        flg = False
        sl = len(s) - 1
        for i in range(sl, 0, -1):
            if not s[i] == s[i-1]:
                s = s[:i-1] + s[i+1:]
                flg = True
                break

    return length - len(s)


def main():
    input = sys.stdin.readline
    s = input().strip()

    print(r(s))


if __name__ == '__main__':
    main()
