#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int m[367];
  int f[367];
  char c;
  int a, b;
  memset(m, 0, sizeof(m));
  memset(f, 0, sizeof(f));
  for (int i = 0; i < n; i++) {
    cin >> c;
    cin >> a >> b;
    if (c == 'M') {
      for (int j = a; j <= b; j++) {
        m[j]++;
      }
    } else {
      for (int j = a; j <= b; j++) {
        f[j]++;
      }
    }
  }
  int re = 0;
  for (int i = 1; i < 367; i++) {
    if (re < min(m[i], f[i])) re = min(m[i], f[i]);
  }
  cout << re * 2 << endl;
  return 0;
}
