def func(line):
    lp = 0
    res = ""
    while lp + 1 < len(line):
        if line[lp] != line[lp + 1]:
            lp += 2
        else:
            res += line[lp]
            lp += 1
    if lp == len(line) - 1:
        res += line[-1]
    return res


def main():
    line = input()
    startsize = len(line)
    while True:
        next = func(line)
        if len(line) == len(next):
            break
        line = next
    lastsize = len(line)
    print(startsize - lastsize)


if __name__ == "__main__":
    main()

