#include <bits/stdc++.h>
using namespace std;
int toint(const string &s) {
  stringstream ss;
  ss << s;
  int x;
  ss >> x;
  return x;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int male[368] = {0};
  int fem[368] = {0};
  for (int i = 0; i < n; i++) {
    char ch;
    cin >> ch;
    int a, b;
    cin >> a >> b;
    if (ch == 'M') {
      male[a] += 1;
      male[b + 1] -= 1;
    } else {
      fem[a] += 1;
      fem[b + 1] -= 1;
    }
  }
  for (int i = 1; i < 368; i++) {
    male[i] = male[i - 1] + male[i];
    fem[i] = fem[i - 1] + fem[i];
  }
  int ans = 0, max = 0;
  ;
  for (int i = 0; i < 368; i++) {
    int temp = min(male[i], fem[i]);
    if (temp > max) {
      ans = 2 * temp;
      max = temp;
    }
  }
  cout << ans << '\n';
  return 0;
}
