#include <bits/stdc++.h>
using namespace std;
int n;
int mvis[400], fvis[400];
int main() {
  while (scanf("%d", &n) != EOF) {
    getchar();
    char sex;
    int s, t;
    memset(mvis, 0, sizeof(mvis));
    memset(fvis, 0, sizeof(fvis));
    for (int i = 0; i < n; i++) {
      scanf("%c%d%d", &sex, &s, &t);
      getchar();
      if (sex == 'M') {
        for (int i = s; i <= t; i++) mvis[i]++;
      }
      if (sex == 'F') {
        for (int i = s; i <= t; i++) fvis[i]++;
      }
    }
    int res = -1;
    for (int i = 1; i <= 366; i++) {
      int tmp = min(mvis[i], fvis[i]);
      if (res == -1 || res < tmp * 2) res = tmp * 2;
    }
    printf("%d\n", res);
  }
  return 0;
}
