#include <bits/stdc++.h>
using namespace std;
struct student {
  char ch;
  int x;
  int y;
} array1[5010];
int main() {
  int minimum = 367, maximum = 0;
  int n;
  cin >> n;
  int count1, count2;
  for (int i = 0; i < n; i++) {
    cin >> array1[i].ch >> array1[i].x >> array1[i].y;
    minimum = min(minimum, array1[i].x);
    maximum = max(maximum, array1[i].y);
  }
  int maximum1 = 0;
  for (int i = minimum; i <= maximum; i++) {
    count1 = 0, count2 = 0;
    for (int j = 0; j < n; j++) {
      if (array1[j].ch == 'M') {
        if (i >= array1[j].x && i <= array1[j].y) count1++;
      }
      if (array1[j].ch == 'F') {
        if (i >= array1[j].x && i <= array1[j].y) count2++;
      }
    }
    int t = min(count1, count2);
    maximum1 = max(maximum1, t);
  }
  cout << 2 * maximum1 << endl;
  return 0;
}
