#include <bits/stdc++.h>
using namespace std;
const int nmax = 110;
const int inf = 1e9 + 7;
const int modulo = 1e9 + 7;
const double linf = 1e36;
const double pi = acos(-1.0);
int n, a, b, d, c[2][400], ans;
char k;
int main() {
  scanf("%d", &n);
  while (n--) {
    while (k = getchar(), k == ' ' || k == '\n')
      ;
    scanf("%d%d", &a, &b);
    if (k == 'M')
      d = 0;
    else
      d = 1;
    for (int i = a; i <= b; ++i) ++c[d][i];
  }
  for (int i = 1; i <= 366; ++i)
    ans = ((ans) > (((c[0][i]) < (c[1][i]) ? (c[0][i]) : (c[1][i])))
               ? (ans)
               : (((c[0][i]) < (c[1][i]) ? (c[0][i]) : (c[1][i]))));
  printf("%d\n", ans * 2);
  return 0;
}
