#include <bits/stdc++.h>
using namespace std;
int N, l, r;
string op;
int A[2][555], sol;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (int I = 0; I < N; I++) {
    cin >> op >> l >> r;
    for (int K = l; K <= r; K++) A[(op == "M") ? 0 : 1][K]++;
  }
  for (int I = 1; I <= 366; I++) {
    sol = max(sol, min(A[0][I], A[1][I]));
  }
  cout << 2 * sol << endl;
}
