#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int main() {
  int n;
  scanf("%d", &n);
  vector<int> f(367, 0);
  vector<int> m(367, 0);
  while (n--) {
    char c;
    int first, second;
    cin >> c >> first >> second;
    for (int it = first; it <= second; ++it) {
      if (c == 'M')
        m[it]++;
      else
        f[it]++;
    }
  }
  int ans = 0;
  for (int it = 0; it <= 366; ++it) {
    ans = max(ans, min(f[it], m[it]));
  }
  cout << ans * 2 << endl;
  return 0;
}
