// Author: Amey Bhavsar - ameybhavsar24@(github & twitter)
// IDE: Geany on Ubuntu 20.04
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define MOD 1000000007
int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	string s;
	cin >> s;
	deque< char > ans;
	bool r = 0;
	rep(i,0,(int)s.size()) {
		if (s[i] == 'R') {
			r = !r;
			continue;
		}
		if (r) {
			if (ans.size() > 0 && s[i] == ans.front()) {
				ans.pop_front();
			} else {
				ans.push_front(s[i]);
			}
		}
		else {
			if (ans.size() > 0 && s[i] == ans.back()) {
				ans.pop_back();
			} else {
				ans.push_back(s[i]);
			}
		}
	}
	
	for (int i=0; i<(int)ans.size(); i++) {
		if (r) {
			cout << ans[(int)ans.size()-1-i];
		} else {
			cout << ans[i];
		}
	}
	cout << '\n';
	
	
	
	return 0;
}

#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;

int P[200005];

int find(int x){
    if (P[x] == 0) return x;
    return P[x] = find(P[x]);
}

bool join(int x, int y){ // 1 on non-trivial join
    int a = find(x), b = find(y);
    if (a == b) return 0;
    P[a] = b;
    return 1;
}

int A[200005];

int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> A[i];
    }
    int ans = 0;
    for (int i = 1; i <= n / 2; i++){
        ans += join(A[i], A[n + 1 - i]);
    }
    cout << ans << endl;
}