#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> mal(370, 0), fem(370, 0);
  int n, x, y;
  char ch;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ch >> x >> y;
    if (ch == 'M') {
      for (int i = x; i <= y; i++) {
        if (i == 366)
          mal[1]++;
        else
          mal[i]++;
      }
    } else {
      for (int i = x; i <= y; i++) {
        if (i == 366)
          fem[1]++;
        else
          fem[i]++;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++) ans = max(ans, 2 * min(fem[i], mal[i]));
  cout << ans;
}
