#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  string S;
  cin >> S;
  string T;
  bool rev = false;
  string revT;
  for (int i = 0; i < S.length(); i++){
    if (S[i] == 'R') {
      rev = !rev;
    }
    else {
      if (rev) revT += S[i];
      else T += S[i];
    }
  }
  reverse(revT.begin(), revT.end());
  T.insert(0, revT);
  if (rev) reverse(T.begin(), T.end());
  int i = 0;
  while (i < (int) T.length()-1) {
    if (T[i] == T[i+1]) {
      T.erase(i, 2);
      if (i>0) i--;
    }
    else i++;
  }
  cout << T << endl;
}

#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define rep(i,n) for(ll i=0;i<n;i++)
int main(){
    string S; cin >> S;
    ll N = S.length();
    deque<char> dq; 
    ll rr[N] = {};
    rep(i, N){      
        if(i == 0){
            if(S[i] == 'R'){
                rr[i] = 1;
            }
            else {
                rr[i] = 0;
                dq.push_back(S[i]);
            }
        }
        else {
            if(S[i] == 'R'){
                rr[i] = rr[i-1] + 1;
            }
            else {
                rr[i] = rr[i-1];
                if(rr[i-1] %2 == 0 ){
                    if(dq.size() &&  S[i] == dq.back() ){
                        dq.pop_back();
                    }
                    else {
                        dq.push_back(S[i]);
                    }
                }
                else {
                    if(dq.size() &&  S[i] == dq.front() ){
                        dq.pop_front();
                    }
                    else {
                        dq.push_front(S[i]);
                    }
                }
            }
        }
    }
    if(rr[N-1] %2 != 0) reverse(dq.begin(), dq.end());
    rep(i,dq.size()) cout << dq[i];
    cout << endl;   
}