#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<char, pair<int, int>>> fr(n);
  for (int i = 0; i < n; ++i)
    scanf(" %c %d %d", &fr[i].first, &fr[i].second.first, &fr[i].second.second);
  int max = 0;
  for (int i = 1; i <= 366; ++i) {
    int m = 0, w = 0;
    for (int j = 0; j < n; ++j) {
      if (i >= fr[j].second.first && i <= fr[j].second.second) {
        if (fr[j].first == 'M')
          ++m;
        else
          ++w;
      }
    }
    int cur = min(m, w) * 2;
    if (cur > max) max = cur;
  }
  printf("%d\n", max);
  return 0;
}
