#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int n, a[400], b[400], res;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char c;
    int l, r;
    cin >> c >> l >> r;
    if (c == 'M') {
      for (int j = l; j <= r; j++) a[j]++;
    } else
      for (int j = l; j <= r; j++) b[j]++;
  }
  for (int i = 1; i <= 366; i++) res = max(res, 2 * min(a[i], b[i]));
  cout << res << endl;
}
