#include<bits/stdc++.h>
#define ll long long
using namespace std;

void readFile(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

const ll MOD = 1e9 + 7;


int main(){
    
    readFile();
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	string s;
	cin >> s;
	deque<char> d;
	int n = (int)s.length();
	bool rev = false;
	for(int i = 0 ; i < n ; ++i){
		if(s[i] == 'R'){
			rev = !rev;
		}
		else{
			if(rev){
				d.push_front(s[i]);
			}
			else{
				d.push_back(s[i]);
			}
		}
	}
	vector<char> a;
	for(auto i : d){
		a.push_back(i);
	}
	vector<char> bb;
	for(int i = 0 ; i < (int)a.size() ; ++i){
		bool ok = false;
		while(!bb.empty() && bb.back() == a[i]){
			bb.pop_back();
			ok = true;
		}
		if(!ok) bb.push_back(a[i]);
	}
	if(rev){
		reverse(bb.begin(), bb.end());
	}
	for(auto i : bb) cout << i;
	cout << '\n';
	return 0;
}
#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

template<typename T>
void printArray(vector<T> &printVec) {
    if(printVec.empty()) return;
    cout << printVec[0];
    for(int i = 1; i < printVec.size(); ++i) cout << " " << printVec[i];
    cout << endl;
}

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    bool f = false;
    deque<char> d;
    for(char c : s) {
        if(c == 'R') {
            f = !f;
        } else {
            if(f) d.push_front(c);
            else d.pb(c);
        }
    }

    stack<char> st;
    if(f) {
        while(!d.empty()) {
            char c = d.back();
            d.pop_back();
            if(!st.empty() && st.top() == c) {
                st.pop();
            } else {
                st.push(c);
            }
        }
    } else {
        while(!d.empty()) {
            char c = d.front();
            d.pop_front();
            if(!st.empty() && st.top() == c) {
                st.pop();
            } else {
                st.push(c);
            }
        }
    }

    string t = "";
    while(!st.empty()) {
        t += st.top();
        st.pop();
    }
    reverse(all(t));
    cout << t << endl;
    return 0;
}

