#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int boys[367] = {0};
  int girls[367] = {0};
  while (n--) {
    char g;
    int l, r;
    cin >> g >> l >> r;
    int *ref;
    if (g == 'M') {
      ref = boys;
    } else {
      ref = girls;
    }
    ref[l] += 1;
    ref[r + 1] -= 1;
  }
  int sumb = 0, sumg = 0;
  for (int i = 1; i <= 366; ++i) {
    sumb += boys[i];
    sumg += girls[i];
    boys[i] = sumb;
    girls[i] = sumg;
  }
  int res = 0;
  for (int i = 1; i <= 366; i++) {
    res = max(res, 2 * min(boys[i], girls[i]));
  }
  cout << res << '\n';
}
