#include <bits/stdc++.h>
using namespace std;
int fm[367], ff[367];
int main() {
  int m, x, y;
  scanf("%d", &m);
  char c;
  for (int i = 1; i <= m; i++) {
    cin >> c >> x >> y;
    if (c == 'M') {
      for (int j = x; j <= y; j++) fm[j]++;
    } else if (c == 'F') {
      for (int j = x; j <= y; j++) ff[j]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++) ans = max(ans, 2 * min(fm[i], ff[i]));
  printf("%d\n", ans);
  return 0;
}
