#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[5003], b[5005], u[500], v[500], i, j, maxi = 0, x;
  char c[5003];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    cin >> c[i];
    cin >> a[i];
    cin >> b[i];
  }
  for (i = 0; i < 400; i++) u[i] = 0, v[i] = 0;
  for (i = 0; i < n; i++) {
    for (j = a[i]; j <= b[i]; j++) {
      if ('F' == c[i])
        u[j]++;
      else
        v[j]++;
    }
  }
  for (i = 0; i < 400; i++) {
    x = min(u[i], v[i]);
    if (maxi < x) maxi = x;
  }
  printf("%d", maxi * 2);
  return 0;
}
