#include <bits/stdc++.h>
using namespace std;
int arr[370], arr1[370];
int main() {
  int n, i, j, cnt, k;
  char c;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> c >> j >> k;
    if (c == 'M') {
      arr[j] += 1;
      arr[k + 1] += (-1);
    } else {
      arr1[j] += 1;
      arr1[k + 1] += (-1);
    }
  }
  for (i = 1; i <= 366; i++) {
    arr[i] = arr[i] + arr[i - 1];
    arr1[i] += arr1[i - 1];
  }
  int ans = 0;
  for (i = 1; i <= 366; i++) {
    ans = max(ans, 2 * min(arr[i], arr1[i]));
  }
  cout << ans << endl;
  return 0;
}
