#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f;
const double inf = 1e18;
const long long mod = 1e9 + 7;
const unsigned long long mx = 133333331;
inline void RI(int &x) {
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0';
}
int f[400];
int m[400];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(f, 0, sizeof(f));
    memset(m, 0, sizeof(m));
    for (int i = 0; i < n; i++) {
      int a, b;
      char c;
      getchar();
      scanf("%c%d%d", &c, &a, &b);
      if (c == 'F')
        for (int j = a; j <= b; j++) f[j]++;
      else
        for (int j = a; j <= b; j++) m[j]++;
    }
    int ans = 0;
    for (int i = 1; i <= 366; i++) {
      int mi = min(f[i], m[i]);
      ans = max(ans, 2 * mi);
    }
    cout << ans << endl;
  }
  return 0;
}
