#include <bits/stdc++.h>
using namespace std;
long long int maxi = 0;
long long int nc2(long long int n) { return (n * (n - 1)) / 2; }
int m[367];
int f[367];
int main() {
  int n, g;
  cin >> n;
  while (n--) {
    char c;
    int l, r;
    cin >> c >> l >> r;
    if (c == 'M') {
      for (int i = l; i <= r; i++) {
        m[i]++;
      }
    } else {
      for (int i = l; i <= r; i++) {
        f[i]++;
      }
    }
  }
  for (int i = 1; i < 367; i++) {
    g = min(m[i], f[i]);
    if (maxi < g) {
      maxi = g;
    }
  }
  cout << 2 * maxi << endl;
  return 0;
}
