Problem:
Score : 200 points

Problem Statement

Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.

To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:

The 0 key: a letter 0 will be inserted to the right of the string.

The 1 key: a letter 1 will be inserted to the right of the string.

The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.

Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?

Constraints

1 ≦ |s| ≦ 10 (|s| denotes the length of s)

s consists of the letters 0, 1 and B.

The correct answer is not an empty string.

Input

The input is given from Standard Input in the following format:

s

Output

Print the string displayed in the editor in the end.

Sample Input 1

01B0

Sample Output 1

00

Each time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.

Sample Input 2

0BB1

Sample Output 2

1

Each time the key is pressed, the string in the editor will change as follows: 0, (empty), (empty), 1.

Solution in C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Scanner;

class Solver
{
    static void Main(string[] args) {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Solve();
        Console.Out.Flush();
    }

    static void Solve() {
        var s = StrSpan();
        Span<char> span = stackalloc char[s.Length];
        var p = 0;
        for (int i = 0; i < s.Length; i++) {
            var c = s[i];
            if (c == 'B' && p > 0) span[p--] = '-';
            if (c != 'B') span[p++] = s[i];
        }
        Console.WriteLine(span[..p].ToString());
    }
}

class Scanner
{
    const int BUFFER_SIZE = 1024, BEGIN = 33, END = 126, ZERO = 48, NINE = 57;
    static readonly Stream stdin = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[BUFFER_SIZE];
    static int size, p;
    static bool isEof;
  
    [MethodImpl(256)]
    private static byte Read() {
        if (isEof) return default;
        if (p < size) return buffer[p++];
        p = 0;
        if ((size = stdin.Read(buffer, 0, BUFFER_SIZE)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    [MethodImpl(256)]
    private static char Next() {
        byte b;
        do b = Read();
        while (b < BEGIN || END < b);
        return (char) b;
    }
    [MethodImpl(256)]
    public static string Str() {
        var sb = new StringBuilder();
        for (char c = Next(); BEGIN <= c && c <= END; c = (char) Read()) sb.Append(c);
        return sb.ToString();
    }
    [MethodImpl(256)]
    public static ReadOnlySpan<char> StrSpan() {
        var list = new List<char>();
        for (char c = Next(); BEGIN <= c && c <= END; c = (char) Read()) list.Add(c);
        return list.AsSpan();
    }
    [MethodImpl(256)]
    private static int Int() {
        int tmp = Next() - ZERO;
        for (var c = (char) Read(); ZERO <= c && c <= NINE; c = (char) Read()) tmp = tmp * 10 + c - ZERO;
        return tmp;
    }
    [MethodImpl(256)]
    private static long Long() {
        long tmp = Next() - ZERO;
        for (var c = (char) Read(); ZERO <= c && c <= NINE; c = (char) Read()) tmp = tmp * 10 + c - ZERO;
        return tmp;
    }
    [MethodImpl(256)]
    private static double Double() => double.Parse(Str(), CultureInfo.InvariantCulture);
    [MethodImpl(256)]
    public static string ScanLine() {
        var sb = new StringBuilder();
        for (var c = Next(); c != '\n' && c != 0; c = (char)Read()) if (c != '\r') sb.Append(c);
        return sb.ToString();
    }
    [MethodImpl(256)]
    public static T Scan<T>() 
        => default(T) switch 
            {int _ => (T) (object) Int(), long _ => (T) (object) Long(), string _ => (T) (object) Str(), _ => (T) (object) Double()};
    [MethodImpl(256)] public static (T, T) Dual<T>() => (Scan<T>(), Scan<T>());
    [MethodImpl(256)] public static (T, T, T) Tri<T>() => (Scan<T>(), Scan<T>(), Scan<T>());
    [MethodImpl(256)] public static (T, T, T, T) Quad<T>() => (Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>());
    [MethodImpl(256)] public static (T, T, T, T, T) Quint<T>() => (Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>());
    [MethodImpl(256)] public static (T1, T2) Scan<T1, T2>() => (Scan<T1>(), Scan<T2>());
    [MethodImpl(256)] public static (T1, T2, T3) Scan<T1, T2, T3>() => (Scan<T1>(), Scan<T2>(), Scan<T3>());
    [MethodImpl(256)] public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Scan<T1>(), Scan<T2>(), Scan<T3>(), Scan<T4>());
    [MethodImpl(256)] public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Scan<T1>(), Scan<T2>(), Scan<T3>(), Scan<T4>(), Scan<T5>());
    [MethodImpl(256)] public static (T1, T2, T3, T4, T5, T6) Scan<T1, T2, T3, T4, T5, T6>() => (Scan<T1>(), Scan<T2>(), Scan<T3>(), Scan<T4>(), Scan<T5>(), Scan<T6>());
}

static class ListExtention
{
    private class Wrapper<T> { public T[] Array; }
    [MethodImpl(256)]
    public static Span<T> AsSpan<T>(this List<T> list) => Unsafe.As<Wrapper<T>>(list).Array.AsSpan(0, list.Count);
}