#include <bits/stdc++.h>
using namespace std;
int M[400], F[400];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char c;
  int n, a, b;
  cin >> n;
  while (n--) {
    cin >> c >> a >> b;
    if (c == 'M') {
      while (a <= b) M[a++]++;
    } else {
      while (a <= b) F[a++]++;
    }
  }
  int m = 0;
  for (int i = 1; i <= 366; i++) m = max(m, min(M[i], F[i]));
  cout << 2 * m;
  return 0;
}
