#include <bits/stdc++.h>
using namespace std;
static int n, l, r;
static char c;
static int day[5010][2];
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%*c%c%d%d", &c, &l, &r);
      int s = (c == 'M' ? 0 : 1);
      for (int i = l; i <= r; i++) day[i][s]++;
    }
    int ans = INT_MIN;
    for (int i = 1; i <= 366; i++) {
      ans = max(ans, min(day[i][0], day[i][1]) * 2);
    }
    printf("%d\n", ans);
  }
  return 0;
}
