#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, ans = 0, i, j;
  char g[5010];
  int A[5010], B[5010];
  cin >> n;
  for (i = 0; i < n; ++i) cin >> g[i] >> A[i] >> B[i];
  for (i = 1; i <= 366; ++i) {
    int m = 0, f = 0;
    for (j = 0; j < n; ++j)
      if (A[j] <= i && B[j] >= i) {
        if (g[j] == 'M')
          m++;
        else
          f++;
      }
    if (m > f)
      ans = max(ans, 2 * f);
    else
      ans = max(ans, 2 * m);
  }
  cout << ans;
  return 0;
}
