#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int> > g;
vector<int> mt;
vector<char> used;
bool try_kuhn(int v) {
  if (used[v]) return false;
  used[v] = true;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (mt[to] == -1 || try_kuhn(mt[to])) {
      mt[to] = v;
      return true;
    }
  }
  return false;
}
int main() {
  cin >> n;
  int a, b, ans = 0;
  char sex;
  vector<vector<int> > days(367, vector<int>(2, 0));
  for (int i = 0; i < n; ++i) {
    cin >> sex >> a >> b;
    if (sex == 'M') {
      for (int j = a; j <= b; ++j) days[j][0]++;
    } else {
      for (int j = a; j <= b; ++j) days[j][1]++;
    }
  }
  for (int i = 1; i <= 366; ++i) {
    if (min(days[i][0], days[i][1]) > ans) ans = min(days[i][0], days[i][1]);
  }
  cout << ans * 2;
  cin.get();
  cin.get();
  return 0;
}
