#include <bits/stdc++.h>
using namespace std;
const int INF = 3000000;
const int MOD = 1000000007;
const int maxn = 5010;
const int x = 370;
int n;
int f[maxn], m[maxn];
int ans[maxn];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    int a, b;
    cin >> c >> a >> b;
    if (c == 'F') {
      for (int i = a; i <= b; i++) {
        f[i]++;
      }
    } else {
      for (int i = a; i <= b; i++) {
        m[i]++;
      }
    }
  }
  for (int i = 0; i < x; i++) {
    ans[i] = min(f[i], m[i]);
  }
  int maxim = -1;
  for (int i = 0; i < x; i++) {
    if (ans[i] > maxim) maxim = ans[i];
  }
  cout << maxim * 2;
}
