#include <bits/stdc++.h>
using namespace std;
int isprime(long long n) {
  if (n == 2 || n == 3 || n == 5) return 1;
  if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0) return 0;
  long long i;
  for (i = 7; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i - 2) == 0) return 0;
  return 1;
}
long long bs(long long arr[], long long l, long long r, long long x) {
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (arr[m] == x) return m;
    if (arr[m] < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return -1;
}
int main() {
  char f[5005];
  int n, i, j, k, c1(0), c2(0), c(0), a[5005][2], d, t[10010];
  cin >> n;
  for (i = 0, j = 0; i < n; ++i, j += 2) {
    cin >> f[i] >> a[i][0] >> a[i][1];
    t[j] = a[i][0];
    t[j + 1] = a[i][1];
  }
  sort(t, t + 2 * n);
  for (i = 0, j = 1; j < 2 * n; i++, j++) {
    c1 = c2 = 0;
    for (k = 0; k < n; ++k) {
      if (t[i] >= a[k][0] && t[j] <= a[k][1]) {
        if (f[k] == 'M')
          ++c1;
        else
          ++c2;
      }
    }
    if (c < 2 * min(c1, c2)) c = 2 * min(c1, c2);
  }
  cout << c;
}
