#include <bits/stdc++.h>
int min(int a, int b) { return a < b ? a : b; }
int main() {
  static char s[5000 + 1];
  static int aa[5000], bb[5000];
  int n, i, day, max;
  scanf("%d\n", &n);
  for (i = 0; i < n; i++) {
    scanf("%c %d %d", &s[i], &aa[i], &bb[i]);
    if (i < n - 1) scanf("\n");
  }
  max = 0;
  for (day = 1; day <= 366; day++) {
    int kf, km;
    kf = km = 0;
    for (i = 0; i < n; i++)
      if (aa[i] <= day && day <= bb[i])
        if (s[i] == 'F')
          kf++;
        else
          km++;
    if (max < min(kf, km)) max = min(kf, km);
  }
  printf("%d\n", max * 2);
  return 0;
}
