#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <numeric>

typedef long long ll;
typedef unsigned long long int ull;
typedef long double ldb;
 
#define PB push_back
    
#define Fas ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
using namespace std;
 
ll power(ll a,ll b){
    int result=1;
    while(b>0){
        if(b%2 == 1){
            result *= a;
        }
        a *= a;
        b /= 2;
    }
    return result;
}

ll gcd(ll x,ll y){
    ll r;
    while(y!=0&&(r=x%y)!=0){
        x=y;
        y=r;
    }
    return y==0?x:y;
}

void solve(){
    ll n;cin>>n;
   // ll m=1000000007;
    vector<string> v(n);
    string A;
    A="AND";
    string O;
    O="OR";
    for(auto &w:v) cin>>w;
    vector<pair<ll,ll>> sto(n);
    sto[0].first=1;
    sto[0].second=1;
    for(ll i=1;i<n;i++){
        if(v[i-1]==A){
            sto[i].first=sto[i-1].first;
            sto[i].second=sto[i-1].first+(2*sto[i-1].second);
        }else{
            sto[i].second=sto[i-1].second;
            sto[i].first=(2*sto[i-1].first)+sto[i-1].second;
        }
    }
    if(v[n-1]==A){
        cout<<sto[n-1].first<<endl;
    }else{
        cout<<(2*sto[n-1].first)+sto[n-1].second<<endl;
    }
    
}
 
int main(){
    Fas;
//    ll t{};
//    cin>>t;
//
//    while(t--){
        solve();
//    }
    
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long
//Functionn for sorting
int main()
{   
  
    unordered_map<long long int,long long int>mp;
    long long int n;
    cin>>n;
    vector<long long int>a(n);
    for(auto &x: a){
        cin>>x;
        mp[x]++;
    }
    long long int c=(n*(n-1))/2;
    vector<long long int>freq;
    for(auto &x:mp){
        freq.push_back(x.second);
    }
    for(auto &x: freq){
        c-=(x*(x-1))/2;
    }
    cout<<c;
  
  
       
}