#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, u, v;
char c;
int main() {
  map<int, map<int, int> > mtp;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> c;
    cin >> u >> v;
    for (int day = u; day <= v; ++day) mtp[day][(c == 'F') ? 1 : 0] += 1;
  }
  int ans = 0;
  for (int i = 1; i <= 366; ++i) {
    ans = max(ans, min(mtp[i][0], mtp[i][1]) * 2);
  }
  cout << ans << endl;
  return 0;
}
