def main():
    S = list(input())
    count = 0
    while True:
        start_count = count
        for i, val in enumerate(S):
            virtual_i = i
            while_loop = 0
            while True:
                while_loop += 1
                try:
                    if S[virtual_i] != S[virtual_i+1]:
                        S.pop(virtual_i)
                        S.pop(virtual_i)
                        virtual_i -= 1
                        count += 2
                    else:
                        break
                except IndexError:
                    break
        if start_count == count:
            break

    print(count)


if __name__ == "__main__":
    main()
