#include <bits/stdc++.h>
using namespace std;
const int M = 5030 + 15;
const int Q = 1e9 + 7;
int g[M][2];
int main() {
  srand(time(NULL));
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    int ai, bi, t;
    cin >> s >> ai >> bi;
    t = (s == "M") ? 1 : 0;
    g[ai][t]++;
    g[bi + 1][t]--;
  }
  int c[2] = {0, 0};
  int ans = 0;
  for (int i = 0; i < 400; i++) {
    c[0] += g[i][0];
    c[1] += g[i][1];
    ans = max(ans, min(c[0], c[1]) * 2);
  }
  cout << ans;
  return 0;
}
