#include <bits/stdc++.h>
#include<sstream>
#include<string>
#include<vector>
#include <set>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define decimal(ans,w) cout<<fixed<<setprecision(w)<<ans
long long M=1000000007;
using namespace std;
ll fact[10000];
ll power(ll x, unsigned ll y, unsigned ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y / 2, m) % m; 
    p = (p * p) % m; 
  
    return (y % 2 == 0) ? p : (x * p) % m; 
} 
unsigned long long modInverse(unsigned long long n,  
                                            ll p)
{
    return power(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n,
                                 ll r, ll p)
{
    // If n<r, then nCr should return 0
    if (n < r)
        return 0;
    // Base case
    if (r == 0)
        return 1;
    return (fact[n] * modInverse(fact[r], p) % p
            * modInverse(fact[n - r], p) % p)
           % p;
}
int32_t main()
{
  IOS
  string s;
  cin>>s;
  ll n=s.length(),x=0;
  deque<char>t;
  for(ll i=0;i<n;i++)
  {
      if(s[i]=='R')
      {
         x^=1; 
      }
      else if(x)t.push_front(s[i]);
      else t.push_back(s[i]);
  }
  if(x)reverse(t.begin(),t.end());
  string s1;
  for(auto it:t)
  {
      if(s1.length()>0 && s1.back()==it)
      {
          s1.pop_back();
      }
      else s1.push_back(it);
  }
  cout<<s1;
  return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;

int x[10];

int main() {
    string s;
    cin >> s;

    deque<char> d;

    int rev = 0; //1 is hanten
    int cnt = 0;

    rep(i,s.size()) {
        if (s[i] == 'R') rev = ~rev;
        else if (d.empty()) d.push_back(s[i]);
        else {
            if (rev) {
                if (s[i] != d.front()) {
                    d.push_front(s[i]);
                } else {
                    d.pop_front();
                }
            } else {
                if (s[i] != d.back()) {
                    d.push_back(s[i]);
                }else {
                    d.pop_back();
                }
            }
        }
    }
    string t = "";
    // cout << d.size() << endl;
    rep(i,d.size()) t += d[i];
    if (rev) reverse(t.begin(), t.end());
    cout << t << endl;
}