#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string s;
    cin>>s;
    int n = s.size();
    deque<char> q;
    bool f = false;
    for(int i=0;i<n;i++){
        if(s[i] == 'R')f^=1;
        else if(f)q.push_front(s[i]);
        else q.push_back(s[i]);
    }
    stack<char> ans;
    while(q.size()){
        char c = q.front();
        q.pop_front();
        if(ans.size() && ans.top()==c){
            ans.pop();
            continue;
        }
        ans.push(c);
    }
    string ret = "";
    while(ans.size()){
        ret += ans.top();
        ans.pop();
    }
    if(f==false && ret.size())reverse(all(ret));
    cout << ret << endl;
}
#include <bits/stdc++.h>
#include <chrono>

using namespace std;
using namespace chrono;

typedef long long int ll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)
#define Clock high_resolution_clock::now()

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;}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// #define TIME

/******************************************************************************************************************************/


const ll inf = 2e18;
const ll mod = 998244353;
const ll N = 5e3+3;



int main()
{
    auto start_time = Clock;
    FASTIO

    
    string s;
    cin >> s;

    int n = s.size();
    deque<char> ans;
    bool f = 0;
    rep(i,n) {
        if(s[i] == 'R') {
            f ^= 1;
            continue;
        }
        if(f) {
            if(ans.empty() || ans.front() != s[i])
                ans.push_front(s[i]);
            else 
                ans.pop_front();
        }
        else {
            if(ans.empty() || ans.back() != s[i]) 
                ans.pb(s[i]);
            else ans.pop_back();
        }
    }
    if(f) reverse(all(ans));
    for(auto i: ans) cout << i;
    cout << "\n";



    


    auto end_time = Clock;
    #ifndef TIME
        return 0;
    #endif
    cout << "\nTime elapsed: "
    << (double)duration_cast<milliseconds>(end_time-start_time).count() 
    << "ms";


    return 0;
}