#include <bits/stdc++.h>
using namespace std;
char gender[5000];
bool a[5000][367];
int start, finish;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  memset(a, 0, sizeof(a));
  for (int i = 0; i < n; i++) {
    cin >> gender[i];
    cin >> start >> finish;
    for (int j = start; j <= finish; j++) {
      a[i][j] = 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++) {
    int m_cntr = 0, f_cntr = 0;
    for (int j = 0; j < 5000; j++) {
      if (a[j][i] == 1) {
        if (gender[j] == 'F')
          f_cntr++;
        else if (gender[j] == 'M')
          m_cntr++;
      }
    }
    ans = max(ans, min(m_cntr, f_cntr) * 2);
  }
  cout << ans;
}
