#include <bits/stdc++.h>
using namespace std;
int a[500], b[500];
int main() {
  int n, u, v, i, j;
  char s[2];
  while (scanf("%d", &n) != EOF) {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (j = 0; j < n; j++) {
      scanf("%s%d%d", s, &u, &v);
      if (s[0] == 'M') {
        for (i = u; i <= v; i++) a[i]++;
      }
      if (s[0] == 'F') {
        for (i = u; i <= v; i++) b[i]++;
      }
    }
    int ans = 0;
    for (i = 1; i <= 366; i++) {
      if (a[i] <= b[i] && a[i] > ans) {
        ans = a[i];
      }
      if (b[i] <= a[i] && b[i] > ans) {
        ans = b[i];
      }
    }
    printf("%d\n", 2 * ans);
  }
  return 0;
}
