#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> diaM(367, 0);
  vector<int> diaF(367, 0);
  for (int i = 0; i < n; i++) {
    char op;
    int x, y;
    cin >> op >> x >> y;
    if (op == 'M') {
      for (int j = x; j <= y; j++) {
        diaM[j]++;
      }
    } else {
      for (int j = x; j <= y; j++) {
        diaF[j]++;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++) {
    ans = max(ans, min(diaF[i], diaM[i]) * 2);
  }
  cout << ans << endl;
}
