#include <bits/stdc++.h>
using namespace std;
int minn[5000], maxx[5000];
int main() {
  int n, mini = 1000, male = 0, female = 0, ans = 0, c = 0;
  char a[5000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cin >> minn[i] >> maxx[i];
    if (mini > minn[i]) {
      mini = minn[i];
    }
  }
  for (int x = mini; x <= 366; x++) {
    for (int y = 0; y < n; y++) {
      if ((a[y] == 'M') && x >= minn[y] && x <= maxx[y]) {
        male++;
      }
      if ((a[y] == 'F') && x >= minn[y] && x <= maxx[y]) {
        female++;
      }
    }
    c = min(male, female) * 2;
    male = 0;
    female = 0;
    if (ans < c) {
      ans = c;
    }
  }
  cout << ans;
  return 0;
}
