#include <bits/stdc++.h>
using namespace std;
int n, s, e, a[375], b[375], rez;
string st;
char c;
int main() {
  scanf("%d", &n);
  for (int j = 0; j < n; j++) {
    scanf("\n%c%d%d", &c, &s, &e);
    for (int i = s; i <= e; i++) {
      if (c == 'M')
        a[i]++;
      else
        a[i]--;
      b[i]++;
    }
  }
  for (int i = 0; i <= 366; i++) {
    rez = max(rez, b[i] - abs(a[i]));
  }
  printf("%d\n", rez);
  return 0;
}
