#include <bits/stdc++.h>
using namespace std;
inline int IN() {
  int x = 0, ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, b[3][1500], a[3][1500];
void Update(int gen, int idx, bool leaf) {
  if (b[gen][idx]) {
    if (!leaf) {
      a[gen][idx << 1] += b[gen][idx];
      b[gen][idx << 1] += b[gen][idx];
      a[gen][idx << 1 | 1] += b[gen][idx];
      b[gen][idx << 1 | 1] += b[gen][idx];
    }
    b[gen][idx] = 0;
  }
}
void Modify(int gen, int idx, int l, int r, int fr, int bh) {
  Update(gen, idx, l == r);
  if (fr == l && bh == r) {
    a[gen][idx]++;
    b[gen][idx]++;
    return;
  }
  int mid = l + r >> 1;
  if (bh <= mid)
    Modify(gen, idx << 1, l, mid, fr, bh);
  else if (fr > mid)
    Modify(gen, idx << 1 | 1, mid + 1, r, fr, bh);
  else {
    Modify(gen, idx << 1, l, mid, fr, mid);
    Modify(gen, idx << 1 | 1, mid + 1, r, mid + 1, bh);
  }
}
void FindAns(int idx, int l, int r) {
  Update(1, idx, l == r);
  Update(2, idx, l == r);
  if (l == r) {
    a[0][idx] = min(a[1][idx], a[2][idx]);
    return;
  }
  int mid = l + r >> 1;
  FindAns(idx << 1, l, mid);
  FindAns(idx << 1 | 1, mid + 1, r);
  a[0][idx] = max(a[0][idx << 1], a[0][idx << 1 | 1]);
}
int main() {
  n = IN();
  for (int i = 1; i <= n; i++) {
    int sx = getchar(), l = IN(), r = IN();
    if (sx == 'M')
      Modify(1, 1, 1, 366, l, r);
    else
      Modify(2, 1, 1, 366, l, r);
  }
  FindAns(1, 1, 366);
  printf("%d\n", a[0][1] * 2);
}
