#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define swap(a,b) (a^=b^=a^=b)
#define ll long long int
#define ull unsigned long long int
#define uint unsigned int
#define format(a) memset(a,0,sizeof(a))
#define rep(x,y,z) for(int x=y;x<=z;x++)
#define dec(x,y,z) for(int x=y;x>=z;x--)
#define mst(x) memset(x,0,sizeof(x))
const int maxn=2e6+220;
inline int read()
{
    int ans=0;
    char last=' ',ch=getchar();
    while(ch<'0'|ch>'9')last=ch,ch=getchar();
    while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
    if(last=='-')ans=-ans;
    return ans;
}
string s;
int dir=0;
char a[maxn];
int l=1e6+21,r=1e6+20;
int nxt(int pos)
{
    if(dir)return pos+1;
    else return pos-1;
}
int pre(int pos)
{
    if(!dir)return pos+1;
    else return pos-1;
}
int main()
{
    cin>>s;
    rep(i,0,s.size()-1)
    {
        if(s[i]=='R')
        {
            dir^=1;
        }
        else
        {
            if(dir==0)
            {
                a[++r]=s[i];
                if(a[r]==a[r-1]&&l!=r)r-=2;
            }
            else
            {
                a[--l]=s[i];
                if(a[l]==a[l+1]&&l!=r)l+=2;
            }
        }
    }
    if(!dir)rep(i,l,r)cout<<a[i];
    else dec(i,r,l)cout<<a[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)


int main(){
    string s;
    cin >> s;
    string t;
    string ans;
    bool h = false;
    rep(i, s.size()){
        if (s[i] == 'R') h = !h;
        else{
            if (!h) t.push_back(s[i]);
            else t.insert(t.begin(), s[i]);
        }
    }
    
    if (h){
        reverse(t.begin(), t.end());
    }

    for (char c : t){
        if (ans.size() && ans.back() == c) ans.pop_back();
        else ans.push_back(c);
    }
    cout << ans << endl;
}