#include <math.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define max(p, q) ((p) > (q) ? (p) : (q))
#define min(p, q) ((p) < (q) ? (p) : (q))
#define mod
using ll = long long;
using P = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T> >;
const ll INF = 1e18 + 1;
int main()
{
  string s;
  cin >> s;
  int ans = 0;
  rep(i, 0, 10000)
  {
    string t = to_string(i);
    while (t.size() < 4)
      t.insert(t.begin(), '0');
    V<bool> used(10, false);
    bool j = true;
    rep(k, 0, 4)
    {
      if (s[t[k] - '0'] == 'x')
      {
        j = false;
        break;
      }
      used[t[k] - '0'] = true;
    }
    rep(k, 0, 10) if (s[k] == 'o') if (!used[k]) j = false;
    if (j)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

#include <stack>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <unordered_map>
/*#define cin(a) scanf("%d",&a)
#define llcin(a) scanf("%lld",&a)
#define fcin(a) scanf("%lf",&a)
#define cout(a) printf("%d",a)
#define cout_n(a) printf("%d\n",a)
#define cout_d(a) printf("%d ",a)
#define f2cout(a) printf("%.2f",a)
#define f2cout_n(a) printf("%.2f\n",a)
#define f2cout_d(a) printf("%.2f ",a)
#define llcout(a) printf("%lld",a)
#define llcout_n(a) printf("%lld\n",a)
#define llcout_d(a) printf("%lld ",a)*/
using namespace std;
typedef long long ll;
ll cnt;
int n;
string s[100];
int main()
{
    scanf("%d", &n);
    getchar();
    for (int i = 1; i <= n; i++)
        cin >> s[i];
    ll dpTrue[100], dpFalse[100];
    memset(dpTrue, 0, sizeof(dpTrue));
    memset(dpFalse, 0, sizeof(dpFalse));
    dpTrue[0] = dpFalse[0] = 1;
    for (int i = 1; i <= n;i++)
    {
        if(s[i]=="AND")
            dpTrue[i] = dpTrue[i - 1], dpFalse[i] = dpFalse[i - 1] * 2 + dpTrue[i - 1];
        else
            dpTrue[i] = dpTrue[i - 1] * 2 + dpFalse[i - 1], dpFalse[i] = dpFalse[i - 1];
    }
    cout << dpTrue[n];
}