#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
int S[maxn] = {0};
struct node {
  int l, r;
  char sex;
} T[maxn];
inline int read(void) {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      f = -1;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
bool cmp(node a, node b) { return a.r < b.r; }
int main(void) {
  int n = read();
  int left = -1;
  for (int i = 0; i < n; i++) {
    cin >> T[i].sex >> T[i].l >> T[i].r;
  }
  sort(T, T + n, cmp);
  int m = 0, fm = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    left = T[i].r;
    m = fm = 0;
    for (int j = i; j < n; j++) {
      if (T[j].l <= left) {
        if (T[j].sex == 'F')
          fm++;
        else
          m++;
      }
    }
    ans = max(ans, min(m, fm));
  }
  cout << ans * 2;
  return 0;
}
