#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, sum;
  char st[2];
  int num[500][2];
  memset(num, 0, sizeof(num));
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%s%d%d", st, &a, &b);
    for (int i = a; i <= b; i++) {
      if (st[0] == 'M')
        num[i][0]++;
      else
        num[i][1]++;
    }
  }
  sum = 0;
  for (int i = 1; i <= 366; i++) sum = max(sum, min(num[i][0], num[i][1]));
  printf("%d\n", sum * 2);
  return 0;
}
