#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define len(a) (int)a.size()
#define all(a) a.begin(), a.end()

const int INF32 = 1 << 30;
const long long INF64 = 1LL << 60;
const double PI = acos(-1);

int main() {
    string S;
    cin >> S;
    list<char> T;

    int inv = 0;
    rep(i, len(S)) {
        if (S[i] == 'R') {
            inv++;
        }
        else {
            if (inv % 2 == 1) {
                if (!T.empty() && S[i] == T.front()) {
                    T.pop_front();
                }
                else {
                    T.push_front(S[i]);
                }
            }
            else {
                if (!T.empty() && S[i] == T.back()) {
                    T.pop_back();
                }
                else {
                    T.push_back(S[i]);
                }
            }
        }
    }

    if (inv % 2 == 1) T.reverse();
    string ans = "";
    for(auto itr = T.begin(); itr != T.end(); ++itr) {
        ans += *itr;
    }
    
    cout << ans << endl;
}

#include<cstdio>
#define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i)
using namespace std;
const int N=5e5+5;
template<typename T>void read(T &x)
{
	bool neg=false;
	unsigned char c=getchar();
	for(;(c^48)>9;c=getchar())if(c=='-')neg=true;
	for(x=0;(c^48)<10;c=getchar())x=(x<<3)+(x<<1)+(c^48);
	if(neg)x=-x;
}
char s[N],a[2*N];
int n,l=N,r=N;
bool empty=true;
int main()
{
	scanf("%s",s);
	while(s[n])++n;
	F(i,0,n)
	{
		if(s[i]=='R')l^=r^=l^=r;
		else
		{
			if(empty)a[l=r]=s[i],empty=false;
			else 
			{
				if(s[i]==a[r])
				{
					if(l!=r)r-=l<r?1:-1;
					else empty=true;
				}
				else r+=l<r?1:-1,a[r]=s[i],empty=false;
			}
		}
	}
	if(!empty)
	{
		if(l<r)F(i,l,r+1)putchar(a[i]);
		if(l>r)for(int i=l;i>=r;--i)putchar(a[i]);
		if(l==r)putchar(a[l]);
	}
	putchar('\n');
	return 0;
}
