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 Rust (1.15.1) (judge verdict: Accepted)

/// ========== 入力用マクロ ====================================================
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
/// FromStr型, Vec<T: FromStr>, Vec<char>, に対応;
/// 
/// 入力と平行して処理したいときには使えない -> 後述の read() を使用
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


// ========== 常用関数 =======================================================
pub use std::f64::consts::PI;

// 10^9 + 7 で割ったあまりを出力してください
pub const MOD: u64 = 1_000_000_007;

// atcoder文字列, 使うときは`main()`内にコピペ
// let atcoder: Vec<char> = vec!['a', 't', 'c', 'o', 'd', 'e', 'r'];

/// 標準入力から
/// 空白文字で囲まれた1つのトークンを
/// 指定の型に変換する
pub fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

/// 標準入力から1行読み取り
/// 空白文字で区切って
/// 指定の型の`Vec`に格納する
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

/// ユークリッドの互除法より
/// 2数の最大公約数を求める
pub fn gcd(arg1: usize, arg2: usize) -> usize {
    let mut u = if arg1 > arg2 { arg1 } else { arg2 };
    let mut v = if arg1 > arg2 { arg2 } else { arg1 };
    let mut r: usize;
    while v != 0 {
        r = u % v;
        u = v;
        v = r;
    }
    u
}

/// `Vec<usize>` に対して順に `gcd()` を適用して
/// 配列全体の最大公約数を求める
pub fn gcd_vec(v: &[usize]) -> usize {
    let mut r = v[0];
    for i in &v[1..] {
        r = gcd(r, *i);
    }
    r
}

/// `gcd()` を利用して2数の最小公倍数を求める
pub fn lcm(arg1: usize, arg2: usize) -> usize {
    arg1 * arg2 / gcd(arg1, arg2)
}

/// `Vec<usize>` に対して順に`lcm()` を適用して
/// 配列全体の最小公倍数を求める
pub fn lcm_vec(v: &[usize]) -> usize {
    let mut r = v[0];
    for i in &v[1..] {
        r = lcm(r, *i);
    }
    r
}

/// 与えられた `char` が母音であれば `true` を返す
pub fn is_vowel(c: char) -> bool {
    match c {
        'a' | 'i' | 'u' | 'e' | 'o' => true,
        _                           => false,
    }
}

/// プログラムを終了
pub fn exit() {
    std::process::exit(0)
}


// Rustの言語アップデートありがたいです
// 頑張ってください！


// ========== main() ==========================================================


fn main() {
    input! {
        s: String,
    }

    let s: Vec<char> = s.chars().collect();
    let mut display = String::new();
    let mut n = 0;

    for i in &s {
        match *i {
            '0' => { display += "0";
                n += 1;
            },
            '1' => { display += "1";
                n += 1;
            },
            _ => if display.is_empty() {
                continue;
            } else {
                display.remove(n-1);
                n -= 1;
            }
        }
    }

    println!("{}", display);
}

// ========== 以下使い捨て関数 ===================================================