#include <bits/stdc++.h>
using namespace std;
long long a[1000], k[1000];
bool used[1000];
int main() {
  for (long long i = 0; i < 1000; ++i) {
    a[i] = 0;
    k[i] = 0;
  }
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    char p;
    long long x, y;
    cin >> p >> x >> y;
    for (long long j = x; j <= y; ++j)
      if (p == 'M')
        a[j]++;
      else
        k[j]++;
  }
  long long ans = -1000;
  for (long long i = 0; i < 400; ++i) {
    long long tmp = min(a[i], k[i]) * 2;
    if (ans < tmp) ans = tmp;
  }
  cout << ans;
  return 0;
}
