#include <bits/stdc++.h>

#define DeltaCube23 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define minimum(a) *min_element(a.begin(), a.end())
#define maximum(a) *max_element(a.begin(), a.end())
#define MOD 998244353
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i >= (b); i--)

typedef long long int lli;
lli binpow(lli a,lli b,lli m){lli res=1;for(b%=m-1,a%=m;b>0;b>>=1,a=a*a%m)if(b&1)res=res*a%m;return res;}
lli gcd(lli a, lli b) {return b? gcd(b, a%b) : a;}

//#define int lli //CAREFUL
using namespace std;

const int mx=1e6+5;    

int main()
{
    DeltaCube23
    int t=1;
    //cin>>t;
		
    while(t--)
    {		
		string s;
		cin>>s;
		
		deque<char> dq;
		int n = s.length();
		
		int turn = 0;
		forf(i,0,n)
		{
			if(s[i] == 'R')
			turn = 1-turn;
			else if(turn == 0)
			dq.push_back(s[i]);
			else
			dq.push_front(s[i]);
		}
		
		string ns;
		while(!dq.empty())
		{
			char temp = dq.front();
			dq.pop_front();
			ns += temp;
		}
		
		if(turn == 1)
		reverse(ns.begin(), ns.end());
		n = ns.length();
		
		vector<char> ans;
		ans.pb('R');
		int len = 1;
		char prev = ans[len - 1];
		
		forf(i,0,n)
		{
			if(ns[i] == prev)
			{
				ans.pop_back();
				len--;
				prev = ans[len - 1];
			}
			else
			{
				ans.pb(ns[i]);
				prev = ns[i];
				len++;
			}
		}
		n = (int)ans.size();
		forf(i,1,n)
		{
			cout<<ans[i];
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()

const int mod = 1000000007;
const int N = 2e5 + 7;
int vis[N] = {0};

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        vector<int> ans;
        int ma = 0;
        int pos = 0;

        for (int i = 0; i < n; ++i)
        {
            cin >> a[i];
        }
        // for (int i = 0; i < n; ++i)
        // {
        //     if (a[i] != 0)
        //     {
        //         vis[a[i]] = 1;
        //         ans.push_back(0);
        //     }
        //     else
        //     {
        //         pos = i;
        //         break;
        //     }
        // }
        int g = 0;

        for (int i = 0; i < n; ++i)
        {
            vis[a[i]] = 1;
            for (int j = g; j < i + 2; ++j)
            {
                if (!vis[j])
                {
                    ans.push_back(j);
                    g = j;
                    break;
                }
            }
        }
        for (int i : ans)
            cout << i << "\n";
    }
}
/*

10 10 3 3
3 6 8
1 6 10


10 10 4 1
1 2 3 10
5


*/