#include <bits/stdc++.h>
using namespace std;
int n, ans;
int m[400], w[400];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    char ch;
    cin >> ch >> a >> b;
    for (int j = a; j <= b; j++)
      if (ch == 'M')
        m[j]++;
      else
        w[j]++;
  }
  for (int i = 1; i <= 366; i++) ans = max(ans, 2 * min(m[i], w[i]));
  cout << ans;
  return 0;
}
