#include <bits/stdc++.h>
using namespace std;
int m[367], f[367];
int main() {
  memset(m, 0, sizeof(m));
  memset(f, 0, sizeof(f));
  int N;
  cin >> N;
  char ch;
  int a, b;
  for (int i = 0; i < N; ++i) {
    cin >> ch >> a >> b;
    if (ch == 'M')
      for (int j = a; j <= b; ++j) ++m[j];
    else
      for (int j = a; j <= b; ++j) ++f[j];
  }
  int res = 0;
  for (int i = 1; i <= 366; ++i) res = max(res, min(m[i], f[i]) * 2);
  cout << res << endl;
  return 0;
}
