#include <bits/stdc++.h>
using namespace std;
const int T = 367;
int M[T];
int F[T];
int MM[T];
int FF[T];
int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    int x, y;
    cin >> x >> y;
    if (c == 'M') {
      M[x]++;
      M[y + 1]--;
    } else {
      F[x]++;
      F[y + 1]--;
    }
  }
  int mk = 0;
  int fk = 0;
  for (int i = 0; i < T; i++) {
    mk += M[i];
    fk += F[i];
    MM[i] += mk;
    FF[i] += fk;
  }
  int ans = 0;
  for (int i = 0; i < T; i++) {
    if (MM[i] > ans && FF[i] > ans) {
      ans = min(MM[i], FF[i]);
    }
  }
  cout << ans * 2 << endl;
  return 0;
}
