#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, z, k, w, ans;
int A[400], B[400];
char c[2];
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) {
    scanf("%s%d%d", &c, &x, &y);
    if (c[0] == 'M') {
      for (int j = (x); j <= (y); j++) A[j]++;
    } else {
      for (int j = (x); j <= (y); j++) B[j]++;
    }
  }
  for (int i = (1); i <= (366); i++) ans = max(ans, min(A[i], B[i]));
  printf("%d\n", ans * 2);
  return 0;
}
