#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
struct node {
  char s[5];
  int l, r;
} p[5010];
int main() {
  while (~scanf("%d", &n)) {
    int minx = 1e7 + 9, maxn = -1e7 + 9;
    for (int i = 0; i < n; i++) {
      scanf("%s%d%d", p[i].s, &p[i].l, &p[i].r);
      minx = min(minx, p[i].l);
      maxn = max(maxn, p[i].r);
    }
    int ans = 0;
    for (int i = minx; i <= maxn; i++) {
      int s1 = 0, s2 = 0;
      for (int j = 0; j <= n; j++) {
        if (p[j].l <= i && p[j].r >= i) {
          if (p[j].s[0] == 'F')
            s1++;
          else if (p[j].s[0] == 'M')
            s2++;
        }
      }
      s1 = min(s1, s2);
      ans = max(ans, s1 * 2);
    }
    printf("%d\n", ans);
  }
  return 0;
}
