#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const* argv[]) {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > f, h;
  for (int i = 0; i < n; i += 1) {
    char sx[3];
    int a, b;
    scanf("%s %d %d", sx, &a, &b);
    if (sx[0] == 'F') {
      f.push_back(pair<int, int>(a, b));
    } else {
      h.push_back(pair<int, int>(a, b));
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i += 1) {
    int tf = 0;
    int th = 0;
    for (int j = 0; j < f.size(); j += 1) {
      if (f[j].first <= i && i <= f[j].second) ++tf;
    }
    for (int j = 0; j < h.size(); j += 1) {
      if (h[j].first <= i && i <= h[j].second) ++th;
    }
    ans = max(ans, min(tf, th));
  }
  printf("%d\n", 2 * ans);
  return 0;
}
