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

int main(){
  int n;
  cin >> n;
  vector<ll> dp(2, 1);
  rep(i, n){
    string s;
    cin >> s;
    vector<ll> p(2); swap(dp, p);
    rep(j, 2)rep(x, 2){
      int nj = j;
      if (s == "AND") nj &= x;
      else nj |= x;
      dp[nj] += p[j];
    }
  }
  cout << dp[1] << endl;
  return 0;
}
#include<bits/stdc++.h>
#define int ll
#define sz(x) int((x).size())
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
using namespace std;
using ll = long long;
using pi = pair<int,int>;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int minf = 0xc0c0c0c0c0c0c0c0;



signed main() {
    ios::sync_with_stdio(0); cin.tie(0);

    string s; cin>>s;
    int res = 0;
    for (int i=0; i<=8; i++) {
        if (s.substr(i, 4) == "ZONe") ++res;
    }
    cout<<res<<'\n';
    return 0;
}