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