#include <bits/stdc++.h>
using namespace std;
int M[1000] = {};
int F[1000] = {};
int main() {
  char ch;
  int x, y, n, i, cnt, maxsofar = -1000000000;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ch >> x >> y;
    if (ch == 'M') {
      M[x]++;
      M[++y]--;
    } else {
      F[x]++;
      F[++y]--;
    }
  }
  for (i = 1; i <= 366; i++) {
    M[i] += M[i - 1];
    F[i] += F[i - 1];
  }
  for (i = 1; i <= 366; i++) {
    cnt = min(F[i], M[i]);
    maxsofar = max(maxsofar, cnt);
  }
  cout << 2 * maxsofar << endl;
  return 0;
}
