#include <bits/stdc++.h>
using namespace std;
int n, ans;
struct day {
  int f, m;
} d[367];
int main() {
  char c;
  int a, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c >> a >> b;
    if (c == 'M')
      for (int j = a; j <= b; j++) d[j].m++;
    else
      for (int j = a; j <= b; j++) d[j].f++;
  }
  for (int i = 1; i < 367; i++) {
    ans = max(min(d[i].f, d[i].m), ans);
  }
  cout << ans * 2;
  return 0;
}
