#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vll vector<long long int>
#define pll pair<long long int,long long int>
#define mod 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define pi 3.141592653589793238
#define Endl endl
#define endl "\n"
const int N = 1e5 + 5;
const ll infP = 1e18;

void solve()
{
        deque<char> d;
        string s;
        cin >> s;
        bool rev = false;
        for(auto x:s)
        {
                if(x == 'R')
                        rev = !rev;
                else
                {
                        if(rev)
                        {
                                if(d.size() and d.front() == x)
                                        d.pop_front();
                                else
                                        d.push_front(x);
                        }
                        else
                        {
                                if(d.size() and d.back() == x)
                                        d.pop_back();
                                else
                                        d.push_back(x);
                        }
                }
        }
        string ans;
        for(auto x:d)
                ans += x;
        if(rev)
                reverse(ans.begin(),ans.end());
        cout << ans;
}

void debug(ll tt) {}
 
signed main()
{
        FAST;
        int t = 1;
        // cin >> t;
        while(t--)
        {
                solve();
        }
}
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (long long i = (s); i < (long long)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Pll = pair<ll, ll>;

int main() { 
    string s;
    cin >> s;
    vector<vector<P>> indbox(2);
    int nowind = 0, start = 0;
    int slen = s.size();
    rep(i, slen){
        if(s[i]=='R'){
            indbox[nowind].emplace_back(start, i); // [start, i)
            nowind ^= 1;
            start = i+1;
        }
    }
    string res = "";
    int reslen = 0;
    indbox[nowind].emplace_back(start, slen);
    int indlen = indbox[nowind^1].size();
    for(int i=indlen-1;i>=0;i--){
        P now = indbox[nowind^1][i];
        for(int j=now.second-1;j>=now.first;j--){
            // cout << s[j];
            if(reslen == 0 || res[reslen-1]!=s[j]){
                res += s[j];
                reslen++;
            }else{
                if(reslen > 0){
                    res.erase(reslen-1);
                    reslen--;
                }
            }
            // cout << reslen << endl;
        }
    }
    indlen = indbox[nowind].size();
    rep(i, indlen){
        P now = indbox[nowind][i];
        rep2(j, now.first, now.second){
            // cout << s[j];
            if(reslen == 0 || res[reslen-1]!=s[j]){
                res += s[j];
                reslen++;
            }else{
                if(reslen > 0){
                    res.erase(reslen-1);
                    reslen--;
                }
            }
            // cout << reslen << endl;
        }
    }
    cout << res << endl;
    return 0; 
}