#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > mas;
  for (int i = 0; i < n; i++) {
    char c;
    int a, b;
    cin >> c >> a >> b;
    if (c == 'F') {
      mas.push_back(make_pair(a, 0));
      mas.push_back(make_pair(b, 3));
    } else {
      mas.push_back(make_pair(a, 1));
      mas.push_back(make_pair(b, 2));
    }
  }
  sort(mas.begin(), mas.end());
  int ans = 0;
  int F = 0, M = 0;
  for (int i = 0; i < mas.size(); i++) {
    if (mas[i].second == 0) F++;
    if (mas[i].second == 3) F--;
    if (mas[i].second == 1) M++;
    if (mas[i].second == 2) M--;
    if (min(M, F) > ans) ans = min(M, F);
  }
  cout << 2 * ans;
  return 0;
}
