#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  char t[n];
  int l[n];
  int r[n];
  for (int i = 0; i < n; i++) cin >> t[i] >> l[i] >> r[i];
  int ans = 0;
  for (int i = 1; i <= 366; i++) {
    int tot = 0;
    int m = 0;
    int f = 0;
    for (int j = 0; j < n; j++) {
      if (i >= l[j] and i <= r[j]) {
        if (t[j] == 'F') f++;
        if (t[j] == 'M') m++;
        tot++;
      }
    }
    int res = min(m, f);
    if (2 * res > ans) ans = 2 * res;
  }
  cout << ans;
  return 0;
}
