#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const int maxn = 100100;
const int mod = 1000000007;
struct type {
  char c;
  int l, r;
} a[5555];
int n;
int res;
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].c >> a[i].l >> a[i].r;
  }
  for (int d = 1; d <= 366; d++) {
    int m = 0, f = 0;
    for (int i = 0; i < n; i++) {
      if (a[i].c == 'M') {
        if (a[i].l <= d && d <= a[i].r) {
          m++;
        }
      } else {
        if (a[i].l <= d && d <= a[i].r) {
          f++;
        }
      }
    }
    res = max(res, 2 * min(f, m));
  }
  printf("%d", res);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
