#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int F[366] = {0}, M[366] = {0};
  int l, r;
  char type;
  for (int i = 0; i < n; i++) {
    cin >> type >> l >> r;
    if (type == 'F')
      for (int i = l - 1; i < r; i++) F[i]++;
    else
      for (int i = l - 1; i < r; i++) M[i]++;
  }
  int res = 0;
  for (int i = 0; i <= 365; i++) res = max(res, 2 * min(F[i], M[i]));
  cout << res << endl;
  return 0;
}
