atcoder#ZONE2021D. 宇宙人からのメッセージ

宇宙人からのメッセージ

Score : 300300 points

Problem Statement

You are given a ciphertext SS. It can be decrypted by the following procedure:

  • Let TT be an empty string.
  • For each i=1,2,,Si = 1, 2, \dots, |S| in this order, do the following: (S|S| denotes the length of SS)- if the ii-th character of SS is R, reverse TT;
    • if the ii-th character of SS is not R, add that character to the end of TT.
  • if the ii-th character of SS is R, reverse TT;
  • if the ii-th character of SS is not R, add that character to the end of TT.
  • After the operation above, if there are two consecutive same characters in TT, remove those two characters. Repeat this operation as long as it can be done. (We can prove that the final string obtained does not depend on the order the characters are removed.)

Print the string TT obtained by this procedure.

Constraints

  • SS consists of lowercase English letters and R.
  • 1S5×1051 \leq |S| \leq 5 \times 10^5

Input

Input is given from Standard Input in the following format:

SS

Output

Print the answer.

ozRnonnoe
zone

We can decrypt it as follows:

  • Initially, TT is an empty string.
  • Add o at the end of TT, making it o.
  • Add z at the end of TT, making it oz.
  • Reverse TT, making it zo.
  • Add n at the end of TT, making it zon.
  • Add o at the end of TT, making it zono.
  • Add n at the end of TT, making it zonon.
  • Add n at the end of TT, making it zononn.
  • Add o at the end of TT, making it zononno.
  • Add e at the end of TT, making it zononnoe.
  • Delete two consecutive ns from TT, making it zonooe.
  • Delete two consecutive os from TT, making it zone.
hellospaceRhellospace

The answer may be an empty string.