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