#include <bits/stdc++.h>
typedef struct {
  char g;
  int a, b;
} friend_t;
int main(void) {
  int n, i, j, ans, f, m;
  friend_t fr[5100];
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("\n%c%d%d", &fr[i].g, &fr[i].a, &fr[i].b);
  ans = 0;
  for (i = 1; i <= 366; ++i) {
    f = 0;
    m = 0;
    for (j = 0; j < n; ++j)
      if (fr[j].a <= i && i <= fr[j].b) {
        if (fr[j].g == 'M')
          ++m;
        else
          ++f;
      }
    ans = (((ans) > (2 * (((m) < (f)) ? (m) : (f))))
               ? (ans)
               : (2 * (((m) < (f)) ? (m) : (f))));
  }
  printf("%d", ans);
  return 0;
}
