#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    deque<char> ans;
    
    bool f=false;
    
    for(char c:S){
        if(c=='R'){
            f^=1;
        }else{
            if(!f){
                ans.push_back(c);
                if(si(ans)>=2&&ans[si(ans)-1]==ans[si(ans)-2]){
                    ans.pop_back();
                    ans.pop_back();
                }
            }else{
                ans.push_front(c);
                if(si(ans)>=2&&ans[0]==ans[1]){
                    ans.pop_front();
                    ans.pop_front();
                }
            }
        }
    }
    
    if(f){
        for(int i=si(ans)-1;i>=0;i--) cout<<ans[i];
        cout<<endl;
    }else{
        for(int i=0;i<si(ans);i++) cout<<ans[i];
        cout<<endl;
    }
}

#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define debug(x) cerr << #x << ": " << x << endl
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define set0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dwn(i,a,b) for(int i=(a);i>=(b);i--)
#define ceil(_,__) (_+(__-1))/__
#define INF 0x3f3f3f3f
#define ll_INF 0x7f7f7f7f7f7f7f7f
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;

inline int read()
{
	int x=0,y=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') y=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*y;
}

deque<char> dq;

int main(){
	bool fl=false;
	
	char ch;
	while(cin>>ch)
		if(ch=='R') fl^=1;
		else if(fl) dq.pf(ch);
		else if(!fl) dq.pb(ch);
	
	string res;
	while(dq.size()){
		if(res.size() && res.back()==dq.front()) res.pop_back();
		else res+=dq.front();
		
		dq.pop_front();
	}
	if(fl) reverse(res.begin(), res.end());
	cout<<res<<endl;

    return 0;
}