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