#include <bits/stdc++.h>
using namespace std;
int m[1000000];
int g[1000000];
signed main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    char c;
    cin >> c;
    int a, b;
    cin >> a >> b;
    if (c == 'M') {
      for (int j = a; j <= b; ++j) {
        m[j]++;
      }
    } else {
      for (int j = a; j <= b; ++j) {
        g[j]++;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= 400; ++i) {
    ans = max(ans, min(g[i], m[i]));
  }
  cout << ans * 2 << endl;
}
