#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='1' || s[i]=='0' || s[i]=='8')
		cout<<s[i];
		if(s[i]=='6')
		cout<<'9';
		if(s[i]=='9')
		cout<<'6';
	}
	return 0;
}
#include<bits/stdc++.h>
#define ll long long int
#define f first
#define s second
#define pb(x) push_back(x)
#define inf (int)1e9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define imax INT_MAX
#define imin INT_MIN

using namespace std;

char c[5000000];

void input() {

	string s;
	cin>>s;

	string ans;

	int r=0;

	int x = s.size();

	int l = 500000,r1=500001;

	for(int i=0;i<x;i++) {
		if(s[i] == 'R') {
			r++;
			continue;
		}
		if(r%2) {
			c[l] = s[i];
			l--;
		}
		else {
			c[r1] = s[i];
			r1++;
		}
	}

	string a1;

	for(int i=l+1;i<r1;i++) {
		a1 += c[i];
	}

	if(r%2) {
		reverse(a1.begin(), a1.end());
	}

	ans = a1;
	

	// cout<<a1<<"\n";
	// cout<<ans<<"\n";

	stack<char> st;

	x = ans.size();

	for(int i=0;i<x;i++) {
		if(!st.empty() && st.top() == ans[i]) {
			st.pop();
		}
		else {
			st.push(ans[i]);
		}
	}
    
    string a;

    while(!st.empty()) {
    	a += st.top();
    	st.pop();
    }

    reverse(a.begin(), a.end());

    cout<<a<<"\n";
}

int main(){

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    input();

    return 0;
}
