#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y, mx = -1;
  char male;
  cin >> n;
  vector<pair<int, int> > intervals;
  int intersection[367][2];
  bool gender[n];
  memset(intersection, 0, sizeof(intersection));
  for (int i = 0; i < n; i++) {
    cin >> male >> x >> y;
    intervals.push_back(make_pair(x, y));
    if (male == 'M')
      gender[i] = true;
    else
      gender[i] = false;
  }
  for (int i = 1; i <= 366; i++) {
    for (int j = 0; j < n; j++) {
      if (i >= intervals[j].first && i <= intervals[j].second) {
        if (gender[j])
          intersection[i][0]++;
        else
          intersection[i][1]++;
      }
    }
  }
  for (int i = 1; i <= 366; i++)
    if (min(intersection[i][0], intersection[i][1]) * 2 > mx)
      mx = min(intersection[i][0], intersection[i][1]) * 2;
  cout << mx << endl;
  return 0;
}
