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