#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
const int N = 1005;
const int maxnode = 400005;
vector<pair<int, int> > f, m;
int main() {
  char ch[2];
  int n, a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s%d%d", ch, &a, &b);
    if (ch[0] == 'M') {
      m.push_back(make_pair(a, b));
    } else
      f.push_back(make_pair(a, b));
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++) {
    int sum = 0, sum2 = 0;
    for (int j = 0; j < m.size(); j++) {
      if (m[j].first <= i && m[j].second >= i) sum++;
    }
    for (int j = 0; j < f.size(); j++) {
      if (f[j].first <= i && f[j].second >= i) sum2++;
    }
    ans = max(ans, min(sum, sum2));
  }
  cout << ans * 2 << endl;
}
