#include <iostream>
#include <cstring>

using namespace std;

string s[61];
long long n, memo[61][2];

long long f(int idx, int a)
{
    if (idx == n) return a;
    if (memo[idx][a] != -1) return memo[idx][a];
    return memo[idx][a] = (s[idx] == "OR" ? f(idx + 1, a|1) + f(idx + 1, a|0) : f(idx + 1, a&1) + f(idx + 1, a&0));
}

int main()
{
    cin >> n;
    memset(memo, -1, sizeof(memo));
    for (int i = 0; i < n; i++) cin >> s[i];
    cout << f(0, 1) + f(0, 0) << endl;
}
#include <bits/stdc++.h>
using namespace std;
#define boostIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define mem(a, val) memset(a, val, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define ppcll(x) __builtin_popcountll(x)
void amn(int &x, int y) { x = min(x, y); }
void amx(int &x, int y) { x = max(x, y); }

#define mod 1000000007
const long long INF = 1e18;
// const int N = 5e5 + 5;

signed main() {
	boostIO;
	int n;
	cin >> n;
	vector<pair<int, string> > v;
	for (int i = 0; i < n; i++) {
		string s;
		int t;
		cin >> s >> t;
		v.push_back({t, s});
	}
	sort(v.begin(), v.end());
	cout << v[n - 2].se << endl;
	return 0;
}
// Play Hard Kiddo...