#include <bits/stdc++.h>
using namespace std;
int n;
char c[5005];
int l[5005];
int r[5005];
int solve(int x) {
  int a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    if (x < l[i] || x > r[i])
      continue;
    else {
      if (c[i] == 'M')
        a++;
      else
        b++;
    }
  }
  return min(a, b);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> c[i] >> l[i] >> r[i];
  int ans = 0;
  for (int i = 0; i < 370; i++) {
    ans = max(ans, 2 * solve(i));
  }
  cout << ans << endl;
}
