//红太阳zhouakngyang txdy!
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
using namespace std;
//#define int long long
inline int read()
{
	int sum=0,nega=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')nega=-1;ch=getchar();}
	while(ch<='9'&&ch>='0')sum=sum*10+ch-'0',ch=getchar();
	return sum*nega;
}
int n,L=500001,R=500000,flag,top;
char a[500009],ans[1000009],res[1000009];
char out[1000009];
int main()
{
	scanf("%s",a+1);n=strlen(a+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]=='R')flag^=1;
		else
		{
			if(flag)L--,res[L]=a[i];
			else R++,res[R]=a[i];
		}
	}
	if(!flag)
		for(int i=1;i<=R-L+1;i++)ans[i]=res[i+L-1];
	else 
		for(int i=1;i<=R-L+1;i++)ans[i]=res[R+1-i];
	for(int i=1;i<=R-L+1;i++)
	{
		out[++top]=ans[i];
		while(top!=0&&out[top]==out[top-1])top-=2;
	}
	for(int i=1;i<=top;i++)putchar(out[i]);
	return 0;
	
}


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

int main() {
  string s;
  deque<char> t;
  bool f = 1;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'R'){
      f = !f;
    }else if(t.empty()){
      t.push_back(s.at(i));
    }else if(f){
       if(s.at(i) != t.back()){
         t.push_back(s.at(i));
       }else{
         t.pop_back();
       }
    }else if(!f){
       if(s.at(i) != t.front()){
         t.push_front(s.at(i));
       }else{
         t.pop_front();
       }
    }
  }
  if(!f){
    for(int i = t.size() - 1; i >= 0; i--){
      cout << t.at(i);
    }
  }else{
    for(int i = 0; i < t.size(); i++){
      cout << t.at(i);
    }
  }
}