#include<bits/stdc++.h>
using namespace std;
int main(){
  int arr[4],sum=0;
  for(int i=0;i<3;i++){
    cin>>arr[i];
    int x=arr[i];
    if(x==1) sum+=6;
    else if(x==2) sum+=5;
    else if(x==3) sum+=4;
    else if(x==4) sum+=3;
    else if(x==5) sum+=2;
    else if(x==6) sum+=1;
  }
  cout<<sum;
  return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = (sizeof(int) == 4 ? 1e9 : 2e18) + 1e5;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

vi arr;
int dp[MAXN][3];
int f(int idx, int val) {
  if (idx == arr.size())
    return (val == 1);

  int &ret = dp[idx][val];
  if (~ret)
    return ret;

  ret = 0;
  if (arr[idx]) {
    // AND
    ret += f(idx + 1, val & 0);
    ret += f(idx + 1, val & 1);
  } else {
    // OR
    ret += f(idx + 1, val | 0);
    ret += f(idx + 1, val | 1);
  }
  return ret;
}

// #define MULTIPLE_TEST_CASES
void solve() {
  memset(dp, -1, sizeof dp);
  int n;
  cin >> n;

  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    arr.eb(s.front() == 'A' ? 1 : 0);
  }

  cout << f(0, 0) + f(0, 1) << endl;
}

signed main() {
  // const string FILE_NAME = "";
  // freopen((FILE_NAME + string(".in")).c_str(), "r", stdin);
  // freopen((FILE_NAME + string(".out")).c_str(), "w", stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}