def main():

    s = eval(input())

    res = ''

    for i in s:

        if i == 'B':

            res = res[:-1]

        else:

            res += i

    print(res)



if __name__ == '__main__':

    main()



def main():

    s = eval(input())

    from collections import deque

    c = deque()

    for i in s:

        if i == 'B':

            if c:

                c.pop()

        else:

            c.append(i)

    print((''.join(list(c))))



if __name__ == '__main__':

    main()

def main():
    s = eval(input())
    res = ""
    for i in s:
        if i == "B":
            res = res[:-1]
        else:
            res += i
    print(res)


if __name__ == "__main__":
    main()

def main():
    s = eval(input())
    from collections import deque

    c = deque()
    for i in s:
        if i == "B":
            if c:
                c.pop()
        else:
            c.append(i)
    print(("".join(list(c))))


if __name__ == "__main__":
    main()

-    res = "" +    from collections import deque + +    c = deque() -            res = res[:-1] +            if c: +                c.pop() -            res += i -    print(res) +            c.append(i) +    print(("".join(list(c))))