#include <bits/stdc++.h>
using namespace std;
int n, f[500], m[500];
int main() {
  memset(f, 0, sizeof f);
  memset(m, 0, sizeof m);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    char g;
    cin >> g >> a >> b;
    if (g == 'F') {
      f[a]++;
      f[b + 1]--;
    } else {
      m[a]++;
      m[b + 1]--;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++) {
    f[i] = f[i - 1] + f[i];
    m[i] = m[i - 1] + m[i];
    ans = max(ans, 2 * min(f[i], m[i]));
  }
  cout << ans << endl;
  return 0;
}
