#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<deque>
#include<list>
using namespace std;
using P = pair<int,int>;
using ll = long long;

const long double EPS = 1e-10;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;

int main(){

  string S;
  list<char> T;
  bool rev = false;
  cin >> S;
  for(int i = 0 ; i < S.size() ; i++){
    if(S[i] == 'R')
      rev = !rev;
    else{
      if(rev){
        if(T.front() == S[i])
          T.pop_front();
        else
          T.push_front(S[i]);
      }
      else{
        if(T.back() == S[i])
          T.pop_back();
        else
          T.push_back(S[i]);
      }
    }
  }
  string ans;
  for(auto x : T)
    ans += x;
  if(rev)
    reverse(ans.begin(),ans.end());
  cout << ans << endl;

}

//红太阳zhouakngyang txdy!
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
using namespace std;
//#define int long long
inline int read()
{
	int sum=0,nega=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')nega=-1;ch=getchar();}
	while(ch<='9'&&ch>='0')sum=sum*10+ch-'0',ch=getchar();
	return sum*nega;
}
int n,L=500001,R=500000,flag,top;
char a[500009],ans[1000009],res[1000009];
char out[1000009];
int main()
{
	scanf("%s",a+1);n=strlen(a+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]=='R')flag^=1;
		else
		{
			if(flag)L--,res[L]=a[i];
			else R++,res[R]=a[i];
		}
	}
	if(!flag)
		for(int i=1;i<=R-L+1;i++)ans[i]=res[i+L-1];
	else 
		for(int i=1;i<=R-L+1;i++)ans[i]=res[R+1-i];
	for(int i=1;i<=R-L+1;i++)
	{
		out[++top]=ans[i];
		while(top!=0&&out[top]==out[top-1])top-=2;
	}
	for(int i=1;i<=top;i++)putchar(out[i]);
	return 0;
	
}

