#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int m[367];
  int f[367];
  memset(m, 0, sizeof(m));
  memset(f, 0, sizeof(f));
  for (int i = 0; i < n; i++) {
    char a;
    int k, l;
    cin >> a >> k >> l;
    if (a == 'M') {
      for (int j = k; j <= l; j++) {
        m[j] += 1;
      }
    } else {
      for (int j = k; j <= l; j++) {
        f[j] += 1;
      }
    }
  }
  int mx = 0;
  for (int i = 1; i < 367; i++) {
    if (min(m[i], f[i]) > mx) {
      mx = min(m[i], f[i]);
    }
  }
  cout << mx * 2 << endl;
  return 0;
}
