#include <bits/stdc++.h>
int W[2][367];
int main() {
  int n, s, e;
  char g;
  while (~scanf("%d", &n)) {
    memset(W, 0, sizeof(W));
    while (n--) {
      getchar();
      scanf("%c %d %d", &g, &s, &e);
      int k = g == 'M';
      for (int i = s; i <= e; i++) W[k][i]++;
    }
    int ans = 0, t;
    for (int i = 1; i < 367; i++) {
      t = W[0][i] < W[1][i] ? W[0][i] : W[1][i];
      if (t > ans) ans = t;
    }
    printf("%d\n", 2 * ans);
  }
  return 0;
}
