#include <bits/stdc++.h>

struct node
{
    char c;
    node *pre, *suf;

    node(char c) : c(c), pre(NULL), suf(NULL) {}
};

int main()
{
    std::string s;
    std::cin >> s;
    node *hd = NULL, *tl = NULL, *cur = NULL;
    bool dir = 0;
    for (std::string::iterator it = s.begin(); it != s.end(); ++it)
    {
        if (*it == 'R')
            if (!dir)
            {
                cur = hd;
                dir = 1;
            }
            else
            {
                cur = tl;
                dir = 0;
            }
        else if (!dir)
            if (hd == NULL && tl == NULL)
                hd = tl = cur = new node(*it);
            else if (*it == tl->c)
            {
                if (hd == tl)
                    hd = tl = NULL;
                else
                {
                    tl = cur = tl->pre;
                    tl->suf = NULL;
                }
            }
            else
            {
                cur = new node(*it);
                cur->pre = tl;
                tl->suf = cur;
                tl = cur;
            }
        else
        {
            if (hd == NULL && tl == NULL)
                hd = tl = cur = new node(*it);
            else if (*it == hd->c)
            {
                if (hd == tl)
                    hd = tl = cur = NULL;
                else
                {
                    hd = cur = hd->suf;
                    hd->pre = NULL;
                }
            }
            else
            {
                cur = new node(*it);
                cur->suf = hd;
                hd->pre = cur;
                hd = cur;
            }
        }
    }
    if (hd != NULL && tl != NULL)
        if (!dir)
        {
            while (hd != tl)
            {
                std::cout << hd->c;
                hd = hd->suf;
            }
            std::cout << hd->c << std::endl;
        }
        else
        {
            while (tl != hd)
            {
                std::cout << tl->c;
                tl = tl->pre;
            }
            std::cout << tl->c << std::endl;
        }
    return 0;
}
/* Piyush Sharma*/
 
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main()
{
    ll testcase = 1;
    // ll testcase;
    // cin >> testcase;
 
    while (testcase > 0)
    {
        string s;
        cin >> s;
  
        deque<char> myqueue;
        bool rev = false;
        for (int i = 0; i < s.length(); i++)
        {
            if (s[i] == 'R') {
                rev = rev^1;
            }
            else if ( rev ) {
                myqueue.push_front(s[i]);
            }
            else {
                myqueue.push_back(s[i]);
            }
        }
      
        if ( rev ) {
            reverse(myqueue.begin(), myqueue.end());
        }
        
        vector<char> mystack;
        for ( char c : myqueue ) {
            if ( mystack.size() >= 1 && c == mystack.back() ) {
                mystack.pop_back();
            }
            else {
                mystack.push_back(c);
            }
        }
        
        string res = "";
        for ( int i=0; i<mystack.size(); i++ ) {
            char c = mystack[i];
            res += c;
        }
 
        // cout << "final res = " << res << "\n";
        cout << res;
 
        testcase--;
    }
    return 0;
}