#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1LL << 60;
const int inf = (1 << 30);
const ll mod = 998244353;
const ll MOD = 1000000007;
const ld PI = acos(-1.0L);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    string s;
    cin >> s;
    deque<char>deq;
    int n = s.size();
    bool frip = false;
    for(int i=0;i<n;i++){
        char c = s[i];
        if(s[i]=='R') frip = !frip;
        else{
            if(deq.empty()){
                if(frip) deq.push_front(c);
                else deq.push_back(c);
            }
            else{
                if(frip){
                    if(deq.front()==c){
                        deq.pop_front();
                    }
                    else{
                        deq.push_front(c);
                    }
                }
                else{
                    if(deq.back()==c){
                        deq.pop_back();
                    }
                    else{
                        deq.push_back(c);
                    }
                }
            }
        }
    }
    string ans;
    for(char c:deq){
        ans.push_back(c);
    }
    if(frip) reverse(ans.begin(),ans.end());
    cout << ans << endl;
}
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <deque>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <utility>
#include <climits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef pair<ull,ull> pull;
typedef vector<int> vi;
typedef vector<ll> vl;
 
#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define rep(s, i, n) for (int(i) = (s); (i) < (n); (i)++)
#define repe(s, i, n) for (int(i) = (s); (i) <= (n); (i)++)
#define rrep(s, i, n) for (int(i) = (s); (i) > (n); (i)--)
#define rrepe(s, i, n) for (int(i) = (s); (i) >= (n); (i)--)
#define allof(a) (a).begin(), (a).end()

int main(int argc, char const *argv[])
{
    string s;
    cin>>s;

    deque<char> T;
    int r=0;

    rep(0,i,s.length()){
        if(s[i]=='R'){
            r=1-r;
        }
        else{
            if(r){
                if(!T.empty()&&T.front()==s[i]){
                    T.pop_front();
                }
                else{
                    T.push_front(s[i]);
                }
            }
            else{
                if(!T.empty()&&T.back()==s[i]){
                    T.pop_back();
                }
                else{
                    T.push_back(s[i]);
                }
            }
        }
    }

    if(r){
        for(auto i=T.rbegin();i!=T.rend();i++){
            cout<<*i;
        }
        cout<<endl;
    }
    else{
        for(auto i=T.begin();i!=T.end();i++){
            cout<<*i;
        }
        cout<<endl;
    }
    
    return 0;
}
