#include <bits/stdc++.h>
using namespace std;
vector<int> blue, green, red;
int demTG() {
int d=0;
for (int b : blue)
for (int g : green)
for (int r : red)
if (b+g>r && b+r>g && g+r>b) d++;
return d;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
for (int i=0; i<n; i++) {
char mau;
int l;
cin>>mau>>l;
switch (mau) {
case 'b': blue.push_back(l); break;
case 'g': green.push_back(l); break;
case 'r': red.push_back(l); break;
}
}
cout<<demTG();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnZlY3RvcjxpbnQ+IGJsdWUsIGdyZWVuLCByZWQ7CmludCBkZW1URygpIHsKICAgIGludCBkPTA7CiAgICBmb3IgKGludCBiIDogYmx1ZSkKICAgICAgICBmb3IgKGludCBnIDogZ3JlZW4pCiAgICAgICAgICAgIGZvciAoaW50IHIgOiByZWQpCiAgICAgICAgICAgICAgICBpZiAoYitnPnIgJiYgYityPmcgJiYgZytyPmIpIGQrKzsKICAgIHJldHVybiBkOwp9CmludCBtYWluKCkgewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBpbnQgbjsKICAgIGNpbj4+bjsKICAgIGZvciAoaW50IGk9MDsgaTxuOyBpKyspIHsKICAgICAgICBjaGFyIG1hdTsKICAgICAgICBpbnQgbDsKICAgICAgICBjaW4+Pm1hdT4+bDsKICAgICAgICBzd2l0Y2ggKG1hdSkgewogICAgICAgICAgICBjYXNlICdiJzogYmx1ZS5wdXNoX2JhY2sobCk7IGJyZWFrOwogICAgICAgICAgICBjYXNlICdnJzogZ3JlZW4ucHVzaF9iYWNrKGwpOyBicmVhazsKICAgICAgICAgICAgY2FzZSAncic6IHJlZC5wdXNoX2JhY2sobCk7IGJyZWFrOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQ8PGRlbVRHKCk7CiAgICByZXR1cm4gMDsKfQ==