#include <bits/stdc++.h>
using namespace std;
int main() {
  int b[367] = {0}, g[367] = {0}, n, i, j, p;
  cin >> n;
  for (i = 0; i < n; i++) {
    char h;
    int s, e;
    cin >> h >> s >> e;
    for (j = 1; j < 367; j++) {
      if (s <= j && j <= e && h == 'M') b[j]++;
      if (s <= j && j <= e && h == 'F') g[j]++;
    }
  }
  p = 0;
  for (i = 1; i < 367; i++) {
    p = max(p, 2 * min(b[i], g[i]));
  }
  cout << p;
}
