#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
char s[N],t[N],zhan[N];
int top;
int main()
{
	int n;
	scanf("%s",s+1);
	n=strlen(s+1);
	int l=n+1,r=n,rev=0;
	for(int i=1;i<=n;i++)
	if(s[i]=='R') {
		rev^=1;
	} else {
		if(rev) l--,t[l]=s[i];
		else r++,t[r]=s[i];
	}
	for(int i=l;i<=r;i++)
	{
		zhan[++top]=t[i];
		if(zhan[top]==zhan[top-1]) top-=2;
	}
	if(!rev) for(int i=1;i<=top;i++) printf("%c",zhan[i]);
	else for(int i=top;i>=1;i--) printf("%c",zhan[i]);
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1e9+1;
using ll = long long;
using p = pair<int, int>;
using v = vector<int>;

int main() {
  string S;
  cin >> S;
  string T;
  int n = 0;
  bool R = false;
  for (auto x : S) {
    if (x == 'R') {
      R = !R;
    } else {
      int j = 0;  
      if (R) {
        j = 0;
        if (x == T[j]) {
          n--;
          T = T.substr(1);
          continue;
        }
        T = x + T;
      } else {
        j = n-1;
        if (x == T[j]) {
          n--;
          T = T.substr(0, n);
          continue;
        }
        T += x;
      }
      n++;
    }
  }
  if (R) reverse(all(T));
  cout << T << endl;
  return 0;
}