#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e6 + 5;
char s[MAXN];
struct Deque {
	bool rev;
    char buffer[MAXN << 1];
    int head = MAXN, tail = MAXN - 1;
    bool empty() {
		return tail < head;
	}
    int size() {
		return tail - head + 1;
	}
    char front() {
		return rev ? buffer[tail] : buffer[head];
	}
    char back() {
		return rev ? buffer[head] : buffer[tail];
	}
    void push_front(int x) {
		rev ? buffer[++tail] = x : buffer[--head] = x;
	}
    void push_back(int x) {
		rev ? buffer[--head] = x : buffer[++tail] = x;
	}
    void pop_back() {
		rev ? head++ : tail--;
	}
    void pop_front() {
		rev ? tail-- : head++;
	}
    void reverse() {
		rev ^= 1;
	}
}Q;

signed main(int argc, char *argv[]) {
    cin >> s + 1;
    int n = strlen(s + 1);
    for (int i = 1; i <= n; ++i) {
        if (s[i] == 'R') Q.reverse();
        else {
            if (!Q.empty() && Q.back() == s[i]) {
				Q.pop_back(); 
				continue;
			}
            else Q.push_back(s[i]);
        }
    }
    while (!Q.empty()) cout << Q.front(), Q.pop_front();
	system("pause");
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main(){
  string S; cin >> S;
  list<char> T;
  bool f=false;
  for(int i=0; i<S.size(); i++){
    if(S[i]=='R'){
      f=!f;
    }else if(f==true){
      if(T.front()==S[i]) T.pop_front();
      else T.push_front(S[i]);
    }else{
      if(T.back()==S[i]) T.pop_back();
      else T.push_back(S[i]);
    }
  }
  string T2="";
  for(char t: T){
    T2+=t;
  }
  if(f==true){
    reverse(T2.begin(), T2.end());
  }
  
  cout << T2 << endl;
}