#include <bits/stdc++.h>
using namespace std;
int male[368], fmale[368];
int main() {
  int n, x, y;
  char ch;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ch >> x >> y;
    if (ch == 'M') {
      for (int j = x; j <= y; j++) {
        male[j]++;
      }
    } else {
      for (int j = x; j <= y; j++) {
        fmale[j]++;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++) {
    int tmp = min(male[i], fmale[i]);
    ans = max(ans, tmp * 2);
  }
  cout << ans;
  return 0;
}
