#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int dp[400][2];
  memset(dp, 0, sizeof(dp));
  string s;
  int l, r, i, j, n;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s >> l >> r;
    if (s[0] == 'M') {
      dp[l][0] += 1;
      dp[r + 1][0] -= 1;
    } else {
      dp[l][1] += 1;
      dp[r + 1][1] -= 1;
    }
  }
  int mx = 0;
  for (i = 1; i <= 366; i++) {
    dp[i][0] = dp[i][0] + dp[i - 1][0];
    dp[i][1] = dp[i][1] + dp[i - 1][1];
    mx = max(mx, min(dp[i][0], dp[i][1]) * 2);
  }
  cout << mx << endl;
  return 0;
}
