#include <iostream>
#include <math.h>
#include <vector>
#include <string>
#include <numeric>
#include <unordered_set>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    string t;
    bool reverse_judge=false;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R'){
            reverse_judge = !reverse_judge;
        }
        else{
            if(reverse_judge){
                if(t[0]==s[i]) t.erase(t.begin());
                else t.insert(t.begin(),s[i]);
                //else t = s[i] + t;
            }
            else if( t[t.size()-1]==s[i] ) t.pop_back();
            else t += s[i];
            
        }
    }

    if(reverse_judge){
        reverse(t.begin(),t.end());
    }
    cout << t << endl;
}
// FIRST THINK THEN CODE.

#include<iostream>
#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pll, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define cld complex<ld>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vld vector<ld>
#define vvld vector<vector<ld>>
#define vpll vector<pll>
#define vcld vector<cld>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define PI acos(-1)
#define endl "\n"
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define mset(a,val) memset(a,val,sizeof(a));
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
#define FOR(i,a,b)  for(ll i=a;i<=b;i++)
#define FORR(i,a,b)  for(ll i=a;i>=b;i--)
const ll M = 1000000007;
const ll MM = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T, typename F>
void chmax( T &a, F b) {
	if (b > a)a = b;
}

template<typename T, typename F>
void chmin( T &a, F b) {
	if (b < a)a = b;
}

const ll N = 2e5 + 5;




void OJ() {


#ifndef ONLINE_JUDGE

	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);

#endif

}

int main() {

	IOS;

	OJ();


	string s; cin >> s;

	ll isrev = 0;

	deque<char>ans;
	for (auto d : s) {
		if (d == 'R') {
			isrev = 1 - isrev;
		} else {
			if (!isrev) {
				ans.push_back(d);
			} else {
				ans.push_front(d);
			}
		}
	}

	if (isrev)rev(ans);

	stack<char>lol;

	for (auto d : ans) {
		if (lol.empty() || lol.top() != d) {
			lol.push(d);
			//		cout << d;
		} else {
			lol.pop();
		}
	}
	ans.clear();

	while (sz(lol)) {
		ans.pb(lol.top());
		lol.pop();
	}

	rev(ans);


	for (auto d : ans)cout << d;



	return 0;


}

