#include <bits/stdc++.h>
using namespace std;
const bool print = false;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > V;
  for (int i = (1); i <= (n); i++) {
    char g;
    int a, b;
    cin >> g >> a >> b;
    int typ = (g == 'M') ? 1 : 2;
    V.emplace_back(a, typ);
    V.emplace_back(b + 1, -typ);
  }
  int obm = 0, obk = 0;
  int wyn = 0;
  sort((V).begin(), (V).end());
  for (auto it : V) {
    if (it.second == 1) obm++;
    if (it.second == 2) obk++;
    if (it.second == -1) obm--;
    if (it.second == -2) obk--;
    wyn = max(wyn, min(obm, obk) * 2);
  }
  printf("%d\n", wyn);
}
