#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int num[2][370];
    for (int i = 1; i < 367; i++) {
      num[0][i] = 0;
      num[1][i] = 0;
    }
    char c;
    int a, b;
    for (int i = 0; i < n; i++) {
      cin >> c >> a >> b;
      int s = 0;
      if (c == 'F') s = 1;
      for (int j = a; j <= b; j++) {
        num[s][j]++;
      }
    }
    int max = 0;
    for (int i = 1; i < 367; i++) {
      int mm = min(num[0][i], num[1][i]);
      if (max < mm) {
        max = mm;
      }
    }
    cout << max * 2 << endl;
  }
  return 0;
}
