Keystrokes

Benni was browsing the internet and accidentally picked up a keylogger. Fortunately, Benni’s computer has virus protection which alerted him, but the protection did not remove the virus. Whenever Benni types a password on a web page, he tries to hide it so that the keylogger does not get his passwords. In order to obscure his password, enters it in a strange way. He uses the left and right arrow keys to move the cursor, and erases characters with backspace. If you are given the sequence of keystrokes that Benni used to enter his password, can you figure out what his password is?

The input is one line containing a string of length
$n$. Benni only writes
lowercase letters and numbers, but when he uses the left arrow
key, the right arrow key, or the backspace key, they are
indicated by `L`, `R`, or `B`,
respectively. Neither `B` nor
`L` appear in the string if the cursor
is in front of the first letter and `R`
does not appear if the cursor is after the last letter.

Print one line containing only Benni’s password.

Group |
Points |
Input restrictions |

$1$ |
$10$ |
$1 \leq n \leq 1\, 000\,
000$, neither |

$2$ |
$13$ |
$1 \leq n \leq 1\, 000$ |

$3$ |
$17$ |
$1 \leq n \leq 1\, 000\,
000$, neither |

$4$ |
$24$ |
$1 \leq n \leq 1\, 000\,
000$, |

$5$ |
$36$ |
$1 \leq n \leq 1\, 000\, 000$ |

Sample Input 1 | Sample Output 1 |
---|---|

iLnLnLeLb |
benni |

Sample Input 2 | Sample Output 2 |
---|---|

arnarLLLBBun |
unnar |

Sample Input 3 | Sample Output 3 |
---|---|

password123 |
password123 |