#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 14;
int male[MAX];
int female[MAX];
int main() {
  ios ::sync_with_stdio(false);
  int n;
  cin >> n;
  while (n--) {
    char c;
    cin >> c;
    int a, b;
    cin >> a >> b;
    if (c == 'M') {
      male[a]++;
      male[b + 1]--;
    } else {
      female[a]++;
      female[b + 1]--;
    }
  }
  int lim = 1e3;
  int best = 0;
  for (int i = 1; i <= lim; ++i) {
    male[i] += male[i - 1];
    female[i] += female[i - 1];
    if (male[i] == female[i]) best = max(best, male[i] + female[i]);
    best = max(best, min(male[i], female[i]) * 2);
  }
  cout << best;
  return 0;
}
