#include <bits/stdc++.h>

using namespace std;

int sb, ib, ob;

int main() {
    int n, tmp1, tmp2;
    char c;
    cin >> n;
    for(int i = 0; i < n - 1; i++) {
        cin >> tmp1 >> tmp2 >> c;
        if(c == 'S') sb++;
        else if(c == 'I') ib++;
        else ob++;

    }
    cout << ob * ib * sb << endl;
    return 0;
}