#include <bits/stdc++.h>
const unsigned long long maxn = 370;
using namespace std;
struct node {
  int num;
  int cap;
} f[maxn], m[maxn];
bool cmp(node a, node b) { return a.cap > b.cap; }
int n, a, b;
char c;
int main() {
  cin >> n;
  memset(f, sizeof(f), 0);
  memset(m, sizeof(m), 0);
  for (int i = 0; i < n; i++) {
    cin >> c >> a >> b;
    if (c == 'F') {
      for (int j = a; j <= b; j++) {
        f[j].num = j;
        f[j].cap++;
      }
    } else if (c == 'M') {
      for (int j = a; j <= b; j++) {
        m[j].num = j;
        m[j].cap++;
      }
    }
  }
  sort(f, f + maxn, cmp);
  sort(m, m + maxn, cmp);
  map<int, int> f_m;
  int fi = 0, mi = 0;
  for (; m[mi].cap > 0; mi++) {
    f_m[m[mi].num] = m[mi].cap;
  }
  int res = 0;
  map<int, int>::iterator it;
  for (; f[fi].cap > 0; fi++) {
    it = f_m.find(f[fi].num);
    if (it != f_m.end()) res = max(res, min(f[fi].cap, it->second));
  }
  cout << res * 2 << endl;
  return 0;
}
