#include <bits/stdc++.h>
using namespace std;
class person {
 public:
  person(char g, int a, int b) {
    gender = g;
    start = a;
    end = b;
  };
  char gender;
  int start;
  int end;
};
int main() {
  int n;
  cin >> n;
  vector<person> people;
  for (size_t i = 0; i < n; i++) {
    char g;
    cin >> g;
    int a;
    cin >> a;
    int b;
    cin >> b;
    person someone(g, a, b);
    people.push_back(someone);
  }
  int result = 0;
  for (size_t i = 0; i <= 366; i++) {
    int M = 0, F = 0;
    for (size_t j = 0; j < n; j++) {
      if (i >= people[j].start && i <= people[j].end) {
        if (people[j].gender == 'M') M++;
        if (people[j].gender == 'F') F++;
      }
    }
    result = max(result, 2 * min(M, F));
  }
  cout << result;
  return 0;
}
