#include <bits/stdc++.h>
using namespace std;
struct points {
  char c;
  int l;
  int r;
};
points a[5005];
int main() {
  int n;
  int i;
  int mx = 0;
  int cnt;
  int m = 0;
  int f = 0;
  int j;
  int k;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i].c >> a[i].l >> a[i].r;
  }
  for (i = 1; i <= 366; i++) {
    m = 0;
    f = 0;
    for (j = 0; j < n; j++) {
      if (a[j].l <= i && a[j].r >= i) {
        if (a[j].c == 'F') {
          f++;
        } else {
          m++;
        }
      }
    }
    int cb = min(m, f);
    if ((2 * cb) > mx) {
      mx = 2 * cb;
    }
  }
  cout << mx;
}
