#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int M[366] = {}, F[366] = {};
  for (int i = 0; i < n; i++) {
    char a;
    int date1, date2;
    cin >> a >> date1 >> date2;
    if (a == 'M') {
      for (int j = date1 - 1; j < date2; j++) M[j]++;
    }
    if (a == 'F') {
      for (int j = date1 - 1; j < date2; j++) F[j]++;
    }
  }
  for (int i = 0; i < 366; i++) {
    M[i] = min(M[i], F[i]);
  }
  int result = 0;
  for (int i = 0; i < 366; i++) {
    result = max(result, M[i]);
  }
  cout << 2 * result << endl;
}
