#include <bits/stdc++.h>
using namespace std;
int n, a, b, male[367], famale[367], ans;
char sex;
int main() {
  while (cin >> n) {
    ans = 0;
    for (int j = 0; j < n; j++) {
      cin >> sex >> a >> b;
      for (int i = a; i <= b; i++) {
        if (sex == 'M')
          male[i]++;
        else
          famale[i]++;
      }
    }
    for (int i = 1; i < 367; i++) {
      if (ans < min(male[i], famale[i])) ans = min(male[i], famale[i]);
    }
    cout << ans * 2 << endl;
  }
  return 0;
}
