#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 5;
int opn[N][2], cls[N][2], cnt[N][2], n, l, r, ans;
char c;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c >> l >> r;
    opn[l][(c == 'F')]++;
    cls[r][(c == 'F')]++;
  }
  for (int i = 1; i <= 366; i++) {
    cnt[i][0] = cnt[i - 1][0] + opn[i][0] - cls[i - 1][0];
    cnt[i][1] = cnt[i - 1][1] + opn[i][1] - cls[i - 1][1];
    ans = max(ans, min(cnt[i][0], cnt[i][1]));
  }
  cout << 2 * ans << endl;
  return 0;
}
