#include <bits/stdc++.h>
using namespace std;
int M[370], F[370];
int main() {
  int n, a, b;
  char s;
  cin >> n;
  while (n--) {
    cin >> s >> a >> b;
    if (s == 'M')
      for (int i = a; i <= b; i++) M[i]++;
    else
      for (int i = a; i <= b; i++) F[i]++;
  }
  int maior = 0, pair;
  for (int i = 1; i <= 366; i++) {
    if (M[i] > F[i])
      pair = F[i];
    else
      pair = M[i];
    pair *= 2;
    if (pair > maior) maior = pair;
  }
  cout << maior << endl;
  return 0;
}
