#include <bits/stdc++.h>
using namespace std;
struct Guest {
  char gender;
  int first, last;
};
int main() {
  int n;
  cin >> n;
  vector<Guest> data;
  char gender;
  int first, last;
  for (int i = 0; i < n; ++i) {
    cin >> gender >> first >> last;
    Guest guest;
    guest.gender = gender;
    guest.first = first;
    guest.last = last;
    data.push_back(guest);
  }
  int best = 0;
  for (int date = 1; date <= 366; ++date) {
    int mcount = 0, fcount = 0;
    for (const auto& guest : data) {
      mcount += (guest.gender == 'M') && (guest.first <= date) &&
                (guest.last >= date);
      fcount += (guest.gender == 'F') && (guest.first <= date) &&
                (guest.last >= date);
    }
    best = max(best, min(mcount, fcount) * 2);
  }
  cout << best << endl;
}
