#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int m[400] = {}, f[400] = {};
  long long int n, i, a, b, j;
  char s;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s >> a >> b;
    if (s == 'F') {
      for (j = a; j <= b; j++) f[j]++;
    } else {
      for (j = a; j <= b; j++) m[j]++;
    }
  }
  long long int maxi = -1, p;
  for (i = 1; i < 367; i++) {
    p = min(f[i], m[i]);
    maxi = max(maxi, p);
  }
  cout << 2 * maxi;
}
