#include <bits/stdc++.h>
using namespace std;
long long int b[5005], c[5005];
int main() {
  long long int n, sum = 0, x, y, maxx = 0;
  cin >> n;
  char m;
  for (int i = 1; i <= n; i++) {
    cin >> m;
    cin >> x >> y;
    if (m == 'F') {
      for (int j = x; j <= y; j++) {
        b[j]++;
      }
    } else if (m == 'M') {
      for (int j = x; j <= y; j++) {
        c[j]++;
      }
    }
  }
  for (int i = 1; i <= 366; i++) {
    if (b[i] < c[i])
      maxx = max(2 * b[i], maxx);
    else
      maxx = max(2 * c[i], maxx);
  }
  cout << maxx;
}
