#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64(Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)
#define rep(...) repeat(__VA_ARGS__)

using namespace std;
using i64 = long long;
using u64 = unsigned long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    i64 n;
    cin >> n;

    vector<pair<i64, string>> v(n);
    for (auto &vs : v) cin >> vs.second >> vs.first;

    sort(v.rbegin(), v.rend());

    cout << v[1].second << endl;

    return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second
#define int ll

int dp[70][2];
string arr[70];
int n;
int calc(int ind, bool last){
    if(ind == n){
        return last;
    }
    if(dp[ind][last] != -1){
        return dp[ind][last];
    }
    if(arr[ind] == "AND"){
        return dp[ind][last] = calc(ind + 1, last & 1) + calc(ind + 1, 0);
    }
    else{
        return dp[ind][last] = calc(ind + 1, last | 1) + calc(ind + 1, last);
    }
}
int32_t main(){
    FAST
    cin >> n;
    bool OR = 0;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << calc(0, 0) + calc(0, 1);
    return 0;
}
