#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
inline int read() {
  register int x;
  register char c(getchar());
  register bool k;
  while ((c < '0' || c > '9') && c ^ '-')
    if ((c = getchar()) == EOF) exit(0);
  if (c ^ '-')
    x = c & 15, k = 1;
  else
    x = 0, k = 0;
  while (c = getchar(), c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c & 15);
  return k ? x : -x;
}
const int maxn = 5e3 + 5;
int sex[maxn];
int L[maxn], R[maxn];
int main() {
  int n = read();
  for (int i = 0; i < n; i++) {
    char ch = getchar();
    if (ch == 'F')
      sex[i] = 0;
    else
      sex[i] = 1;
    L[i] = read(), R[i] = read();
  }
  int res = 0;
  for (int i = 1; i <= 366; i++) {
    int tmp0 = 0, tmp1 = 0;
    for (int j = 0; j < n; j++) {
      if (L[j] <= i && i <= R[j])
        if (sex[j] == 0)
          tmp0++;
        else
          tmp1++;
    }
    res = max(res, min(tmp0, tmp1));
  }
  cout << res * 2 << '\n';
  return 0;
}
