#include<bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin>>s;
  deque<char> dq;
  bool b=true;
  for(int i=0;i<int(s.size());i++){
    if(s[i]=='R') b=!b;
    else{
      if(b){
        if(!dq.empty()&&dq.back()==s[i]){
          dq.pop_back();
        }else{
          dq.push_back(s[i]);
        }
      }else{
        if(!dq.empty()&&dq.front()==s[i]){
          dq.pop_front();
        }else{
          dq.push_front(s[i]);
        }
      }
    }
  }
  int r=int(dq.size());
  for(int i=0;i<r;i++){
    if(b){
      cout<<dq.front();
      dq.pop_front();
    }else{
      cout<<dq.back();
      dq.pop_back();
    }
  }
}
        
#include <iostream>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <random>
#include <cassert>

typedef long long ll;
using namespace std;

constexpr ll mod007 = 1000000007;
constexpr ll mod998 = 998244353;

int N, A[20];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int Min = INT_MAX;
	for (int i = 0; i < (1 << N); i++) {
		int X = 0;
		int t = 0;
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) {
				X ^= t;
				t = A[j];
			}
			else {
				t |= A[j];
			}
		}
		X ^= t;
		Min = min(Min, X);
	}
	cout << Min << endl;
}