#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int> > v(367);
  char c;
  int n;
  scanf("%d", &n);
  int a, b;
  for (int i = 0; i < n; i++) {
    scanf(" %c%d%d", &c, &a, &b);
    for (int j = a; j <= b; j++)
      if (c == 'M')
        v[j].first++;
      else
        v[j].second++;
  }
  long long ans = 0, z = 1;
  for (int i = 1; i <= 366; i++) {
    ans = max(ans, min(v[i].first, v[i].second) * z * 2);
  }
  cout << ans << endl;
  return 0;
}
