#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<std::pair<int, int> > days(367, std::pair<int, int>(0, 0));
  for (int i = 0; i < n; i++) {
    char gender;
    int a, b;
    std::cin >> gender >> a >> b;
    if (gender == 'M') {
      days[a - 1].first++;
      days[b].first--;
    } else {
      days[a - 1].second++;
      days[b].second--;
    }
  }
  int currentM = 0;
  int currentF = 0;
  int best = 0;
  for (int i = 0; i < 367; i++) {
    currentM += days[i].first;
    currentF += days[i].second;
    if (currentM > best && currentF > best) {
      best = std::min(currentM, currentF);
    }
  }
  best *= 2;
  std::cout << best;
  return 0;
}
