#include <bits/stdc++.h>
int x[370] = {0}, y[370] = {0};
int main(void) {
  int n, i, j, p, q, s = 0, k = 0;
  scanf("%d", &n);
  char a[2];
  for (i = 0; i < n; i++) {
    scanf("%s%d%d", a, &p, &q);
    if (a[0] == 'M')
      for (j = p; j <= q; j++) x[j]++;
    else
      for (j = p; j <= q; j++) y[j]++;
  }
  for (i = 0; i < 367; i++) {
    k = x[i] < y[i] ? x[i] : y[i];
    if (k > s) s = k;
  }
  printf("%d\n", s * 2);
  return 0;
}
