#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int d[2][367] = {0};
  int b, c;
  char a;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (a == 'F') {
      for (int j = b; j <= c; j++) {
        d[0][j]++;
      }
    }
    if (a == 'M') {
      for (int j = b; j <= c; j++) {
        d[1][j]++;
      }
    }
  }
  long long max = 0;
  for (int i = 1; i <= 366; i++) {
    if (min(d[0][i], d[1][i]) > max) {
      max = min(d[0][i], d[1][i]);
    }
  }
  cout << 2 * max;
  return 0;
}
