#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long exp, long long m) {
  long long ans = 1;
  b %= m;
  while (exp) {
    if (exp & 1) ans = (ans * b) % m;
    exp >>= 1;
    b = (b * b) % m;
  }
  return ans;
}
int main() {
  int n, M[400] = {0}, F[400] = {0}, ans = 0, a, b;
  cin >> n;
  char x;
  for (int(i) = (1); i < n + 1; i++) {
    cin >> x >> a >> b;
    if (x == 'M')
      M[a]++, M[b + 1]--;
    else
      F[a]++, F[b + 1]--;
  }
  for (int(i) = (1); i < 367; i++) {
    M[i] += M[i - 1];
    F[i] += F[i - 1];
    int temp = ((F[i]) < (M[i]) ? (F[i]) : (M[i]));
    if (temp > ans) ans = temp;
  }
  cout << ans * 2;
}
