#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define _ << ' ' <<
#define _n << '\n';
#define print(arr) for(int i : arr) cout << i << ' '; cout << '\n';

using namespace std;


pair<long long int,long long int> go(int pos, vector<int> &vec){
    if(pos == 0){
        if(vec[0]){
            return {1, 3};
        }
        else{
            return {3, 1};
        }
    }
    pair<long long int,long long int> p = go(pos-1, vec);
    if(vec[pos]){
        return {p.first, powl(2, pos+1) + p.second};
    }
    return {powl(2, pos+1) + p.first, p.second};
}


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    vector<int> vec;
    for(int i=0;i<n;++i){
        string str; cin >> str; 
        if(str == "AND") vec.push_back(1);
        else vec.push_back(0);
    }
    cout << go(n-1, vec).first << '\n'; 
    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000  //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265358979323846

using namespace std;

#include <sstream>

using namespace std;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

signed main() {
    string an;
    cin >> an;
    cout << split(an, '.')[0] << endl;
}

// int M, H;
// cin >> M >> H;

// if(H%M == 0){
//     cout << "Yes" <<endl ;
// }else{
//     cout << "No" <<endl ;
// }