#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10, INF = 1e9 + 7, M = 1e3;
int ml[N], mr[N], fl[N], fr[N];
int main() {
  char c;
  int i, j, k, n, m, f, t, l, r, ans = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> c >> l >> r;
    if (c == 'M') {
      ml[l]++;
      mr[r]++;
    } else {
      fl[l]++;
      fr[r]++;
    }
  }
  ans = 0;
  m = f = 0;
  for (i = 1; i <= 366; i++) {
    m += ml[i];
    f += fl[i];
    ans = max(ans, min(f, m));
    m -= mr[i];
    f -= fr[i];
  }
  cout << ans * 2 << endl;
  return 0;
}
