#include <bits/stdc++.h>
using namespace std;
int n;
long long m[400];
long long f[400];
void Clear() {
  for (int c = 1; c <= 366; c++) {
    f[c] = m[c] = 0;
  }
}
int main() {
  cin >> n;
  char name;
  int a, b;
  Clear();
  long long maxx = 0;
  while (n-- > 0) {
    cin >> name;
    cin >> a >> b;
    if (name == 'M') {
      for (int c = a; c <= b; c++) {
        m[c]++;
      }
    } else {
      for (int c = a; c <= b; c++) {
        f[c]++;
      }
    }
  }
  for (int c = 1; c <= 366; c++) {
    maxx = max(maxx, 2 * min(m[c], f[c]));
  }
  cout << maxx << endl;
  return 0;
}
