#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
const int N = (int)5e5 + 77;
const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e18;

ll n, m, ans;
map<ll, ll> mp;

int main()
{
  int t = 1;
  // cin >> t;
  while (t--)
  {
    cin >> n;
    ans = 0;
    for (int i = 0; i < n; i++)
    {
      cin >> m;
      ans += i - mp[m];
      mp[m] += 1;
    }
    cout << ans << endl;
  }
  return 0;
}
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<ll> dp(2, 1);
  rep(i, n) {
    vector<ll> temp(2);
    swap(dp, temp);
    string s;
    cin >> s;
    rep(y, 2) rep(x, 2){
      int l;
      if (s == "AND")  l = y & x;
      else l = y | x;
      dp[l] += temp[y];
    }
  }
  cout << dp[1] << endl;
  return 0;
}
