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

int main()
{
  string S;
  cin >> S;
  bool reversed = false;
  deque<char> T;
  for (auto c : S)
  {
    if (c == 'R')
    {
      reversed = !reversed;
      continue;
    }
    if (reversed)
    {
      if (!T.empty() && T.front() == c)
      {
        T.pop_front();
      }
      else
      {
        T.push_front(c);
      }
    }
    else
    {
      if (!T.empty() && T.back() == c)
      {
        T.pop_back();
      }
      else
      {
        T.push_back(c);
      }
    }
  }
  if (reversed)
  {
    reverse(T.begin(), T.end());
  }
  while (!T.empty())
  {
    cout << T.front();
    T.pop_front();
  }
  cout << endl;
}
// Problem: D - Message from Aliens
// Contest: AtCoder - ZONe Energy Programming Contest
// URL: https://atcoder.jp/contests/zone2021/tasks/zone2021_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms

#include <bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll  long long
#define int long long
#define ld  long double
#define endl "\n"
#define pb  push_back
#define fill(a,val) memset(a,val,sizeof(a))
#define ff  first
#define ss  second
#define test  ll t; cin>>t; while(t--)
#define loop(i,a,b)  for(ll i=a;i<b;i++)
#define loopr(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod     = 1000*1000*1000+7;
const ll inf     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll mod2    = 998244353;
const ll N       = 1000 * 1000 + 10;
const ld pi      = 3.141592653589793;
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll ncr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}


void solve(){
    string s;
    cin>>s;
    vector<char> ans;
    for(ll i=0;i<s.length();i++){
    	if(s[i]!='R'){
    		if(ans.size() > 0 && ans[ans.size() - 1]==s[i]){
    			ans.pop_back();
    		}
    		else{
    			ans.pb(s[i]);
    		}
    	}
    	else{
    		reverse(all(ans));
    	}
    }
    for(auto i:ans) cout<<i;
    cout<<endl;
}
signed main(){
    fastio();
    // test
    solve();
    return 0;
}