#include <bits/stdc++.h>
using namespace std;
int main() {
  long int i, j, k, n, p, s, l, a[400] = {0}, b[400] = {0}, ans = 0;
  char ch;
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> ch >> p >> s;
    if (ch == 'M') {
      for (j = p; j <= s; j++) a[j]++;
    } else {
      for (j = p; j <= s; j++) b[j]++;
    }
  }
  for (i = 1; i <= 366; i++) {
    ans = max(ans, min(a[i], b[i]));
  }
  cout << ans * 2 << endl;
  return 0;
}
