#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  char ch;
  int arr[5001], brr[5001], mdays[5001], fdays[5001];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ch >> arr[i] >> brr[i];
    if (ch == 'M') {
      for (int j = arr[i]; j <= brr[i]; j++) mdays[j]++;
    } else {
      for (int j = arr[i]; j <= brr[i]; j++) fdays[j]++;
    }
  }
  int mx = 0;
  for (int i = 1; i <= 366; i++) {
    mx = max(mx, min(mdays[i], fdays[i]));
  }
  mx *= 2;
  cout << mx << endl;
  return 0;
}
