#include <bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;
using lint = long long;

int main(void)
{
    string S;
    cin >> S;

    string T1 = "";
    string T2 = "";
    int t = 1;
    for(int i = 0; i < S.size(); i++){
        if(S[i] != 'R'){
            if(t == 1){
                T1.push_back(S[i]);
            }
            else{
                T2.push_back(S[i]);
            }
            int n_t1 = T1.size() - 1;
            int n_t2 = T2.size() - 1;
            if(T1.size() >= 2 && T1[n_t1] == S[i] && T1[n_t1-1] == S[i]){
                T1.pop_back();
                T1.pop_back();
            }
            else if(T2.size() >= 2 && T2[n_t2] == S[i] && T2[n_t2-1] == S[i]){
                T2.pop_back();
                T2.pop_back();
            }
            else if(T1.size() >= 1 && T2.size() >= 1 && T1[0] == S[i] && T2[0] == S[i]){
                T1.erase(T1.begin());
                T2.erase(T2.begin());
            }
            //cout <<S[i] << " "<< T1 << " " << T2 << endl;
        }
        else{
            t *= -1;
        }
    }

    if(t == 1){
        reverse(T2.begin(), T2.end());
        cout << T2 << T1 << endl;
    }
    else{
        reverse(T1.begin(), T1.end());
        cout << T1 << T2 << endl;
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
    string s, t = "";
    cin >> s;
    int n = s.length();
    bool flip = true;
    deque<char> deq;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            flip = !flip;
        } else {
            if (flip) {
                deq.emplace_front(s[i]);
            } else {
                deq.emplace_back(s[i]);
            }
        }
    }

    if (flip) reverse(deq.begin(), deq.end());

    stack<char> st;
    for (auto c: deq) {
        if (st.size() and st.top() == c) {
            st.pop();
            continue;
        }
        st.push(c);
    }

    stack<char> tmp;

    while (st.size()) {
        char c = st.top();
        st.pop();
        tmp.push(c);
    }

    while (tmp.size()) {
        char c = tmp.top();
        tmp.pop();
        cout << c;
    }
    cout << endl;
}