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