#include <bits/stdc++.h>
using namespace std;
int m[370], f[370];
int main() {
  int n;
  cin >> n;
  char c;
  int r1, r2;
  for (int i = 0; i < n; i++) {
    cin >> c >> r1 >> r2;
    if (c == 'M') {
      for (int j = r1; j <= r2; j++) m[j]++;
    } else {
      for (int j = r1; j <= r2; j++) f[j]++;
    }
  }
  int mx = 0;
  for (int i = 0; i < 370; i++) {
    if (min(m[i], f[i]) > mx) mx = min(m[i], f[i]);
  }
  cout << 2 * mx;
}
