#include <bits/stdc++.h>
using namespace std;
struct frnd {
  char g;
  int x;
  int y;
};
frnd f[5005];
int a[370];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> f[i].g >> f[i].x >> f[i].y;
    }
    int male = 0, fe = 0;
    for (int i = 1; i <= 366; i++) {
      male = 0;
      fe = 0;
      for (int j = 0; j < n; j++) {
        if (f[j].g == 'M') {
          if (i >= f[j].x && i <= f[j].y) male++;
        } else {
          if (i >= f[j].x && i <= f[j].y) fe++;
        }
      }
      a[i] = 2 * min(male, fe);
    }
    cout << a[max_element(a, a + 367) - a] << endl;
    ;
  }
  return 0;
}
