#include <bits/stdc++.h>
using namespace std;
struct g {
  int b, f;
} x[370];
int n;
int main() {
  cin >> n;
  getchar();
  for (int i = 0; i < n; i++) {
    char g = getchar();
    int a, b;
    cin >> a >> b;
    getchar();
    for (int j = a; j <= b; j++) {
      if (g == 'M')
        x[j].b++;
      else
        x[j].f++;
    }
  }
  int maxV = 0;
  for (int i = 1; i < 367; i++) {
    maxV = max(2 * min(x[i].f, x[i].b), maxV);
  }
  cout << maxV << '\n';
  return 0;
}
