#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, maxCnt = 0;
  char x;
  cin >> n;
  int arr[n][4];
  for (int i = 0; i < n; i++) {
    cin >> x >> arr[i][1] >> arr[i][2];
    x == 'F' ? arr[i][0] = 0 : arr[i][0] = 1;
  }
  for (int i = 1; i <= 366; i++) {
    int femaleCnt = 0, maleCnt = 0;
    for (int j = 0; j < n; j++)
      if (i >= arr[j][1] && i <= arr[j][2])
        arr[j][0] == 1 ? maleCnt++ : femaleCnt++;
    maxCnt = max(maxCnt, min(femaleCnt, maleCnt) * 2);
  }
  cout << maxCnt;
  return 0;
}
