#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int n,t,t1,t2;
	string s,s1,s2;

	cin >> n;
	t1=0;
	t2=-1;
	s1="a";
	s2="b";
	rep(i,n){
		cin >> s >> t;
		if(t>t1){
			t2=t1;
			s2=s1;
			t1=t;
			s1=s;
		}else if(t>t2){
			t2=t;
			s2=s;
		}
	}
	cout << s2 << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string S;
  cin >> S;
  deque<char> T;
  int side = 0;
  for (char ch : S) {
    if (ch == 'R') {
      side = 1 - side;
    } else {
      if (side == 0) {
        T.push_back(ch);
      } else {
        T.push_front(ch);
      }
    }
  }
  if (side == 1) {
    side = 0;
    reverse(ALL(T));
  }
  string ans;
  REP(i, T.size()) {
    if (!ans.empty() && ans.back() == T[i]) {
      ans.pop_back();
    } else {
      ans.push_back(T[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}