#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > male;
vector<pair<int, int> > female;
int main() {
  male.clear();
  female.clear();
  int n, r1, r2;
  char type;
  cin >> n;
  int maxx = 0;
  for (int k = 0; k < n; k++) {
    cin >> type >> r1 >> r2;
    if (type == 'M')
      male.push_back(make_pair(r1, r2));
    else
      female.push_back(make_pair(r1, r2));
  }
  int cc, mel, fem;
  for (int k = 1; k <= 366; k++) {
    mel = fem = 0;
    for (int m = 0; m < male.size(); m++) {
      if (k >= male[m].first && k <= male[m].second) mel++;
    }
    for (int f = 0; f < female.size(); f++) {
      if (k >= female[f].first && k <= female[f].second) fem++;
    }
    if (mel == fem)
      maxx = max(maxx, mel + fem);
    else if (mel > fem & fem != 0) {
      maxx = max(maxx, fem * 2);
    } else if (fem > mel & mel != 0) {
      maxx = max(maxx, mel * 2);
    }
  }
  cout << maxx << endl;
}
