#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-12;
inline int sgn(double u) {
  if (u > eps)
    return 1;
  else if (u < -eps)
    return -1;
  else
    return 0;
}
int daysM[399], daysF[399];
int n;
int main() {
  scanf("%d", &n);
  getchar();
  for (int i = 0; i < n; i++) {
    char op;
    int l, r;
    scanf("%c %d %d", &op, &l, &r);
    getchar();
    for (int j = l; j <= r; j++) {
      if (op == 'M')
        daysM[j]++;
      else
        daysF[j]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++) {
    ans = max(ans, min(daysM[i], daysF[i]));
  }
  printf("%d\n", 2 * ans);
  return 0;
}
