#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int fe[400] = {0}, ma[400] = {0};
  while (n--) {
    char cmd;
    int a, b;
    cin >> cmd >> a >> b;
    if (cmd == 'M')
      for (int i = a; i <= b; i++) ma[i] += 1;
    else
      for (int i = a; i <= b; i++) fe[i] += 1;
  }
  int mx = 0;
  for (int i = 1; i <= 366; i++) {
    int x = min(fe[i], ma[i]);
    if (x * 2 > mx) mx = x * 2;
  }
  cout << mx << '\n';
  return 0;
}
