#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    string S;
    cin >> S;
    deque<char> q;
    bool rev = false;
    for(int i = 0;i<S.size();++i){
        if(S[i]=='R') rev ^= 1;
        else if(rev) q.push_front(S[i]);
        else q.push_back(S[i]);
    }
    
    if(rev) reverse(q.begin(),q.end());
    string T;
    for(char c : q){
        if(T.size() && T.back()==c) T.pop_back();
        else T.push_back(c);
    }
    cout << T << endl;
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};

int main()
{
    string s;
    cin >> s;
    bool front = false;
    deque<char> dq;

    for (int i = 0; i < s.size(); i++)
    {
        char c = s[i];
        if (c == 'R')
        {
            front = !front;
        }
        else
        {
            if (front)
            {

                dq.push_front(c);
            }
            else
            {
                dq.push_back(c);
            }
        }
    }
    string s1;
    while (dq.size() > 0)
    {
        char c = dq.front();
        dq.pop_front();
        s1 += c;
    }
    if (front)
    {
        reverse(all(s1));
    }
    if (s1.size() <= 1)
    {
        cout << s1 << endl;
    }
    else
    {
        deque<char> dq2;
        for (int i = 0; i < s1.size(); i++)
        {
            char c = s1[i];
            if(dq2.size()==0 || dq2.back()!=c)
            {
                dq2.push_back(c);
            }
            else
            {
                dq2.pop_back();
            }
        }
        while (dq2.size() > 0)
        {
            cout << dq2.front();
            dq2.pop_front();
        }
        cout << endl;
        
    }

    return 0;
}