#include <bits/stdc++.h>
using namespace std;
int m[400], f[400], t[400];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 400; i++) m[i] = f[i] = t[i] = 0;
  char c;
  int s, e;
  for (int i = 0; i < n; i++) {
    cin >> c >> s >> e;
    if (c == 'M') {
      for (int i = s; i <= e; i++) m[i] += 1;
    }
    if (c == 'F') {
      for (int i = s; i <= e; i++) f[i] += 1;
    }
  }
  for (int i = 1; i <= 366; i++) {
    if (f[i] == 0 || m[i] == 0) continue;
    t[i] = min(f[i], m[i]);
  }
  int ans = -1;
  for (int i = 1; i <= 366; i++) ans = max(ans, t[i]);
  printf("%d\n", ans * 2);
  return 0;
}
