#include <bits/stdc++.h>
using namespace std;
char gender[5005];
int a[5005];
int b[5005];
int main() {
  int n;
  int ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> gender[i] >> a[i] >> b[i];
  for (int i = 0; i < 367; ++i) {
    int f = 0, m = 0;
    for (int j = 0; j < n; ++j)
      if (a[j] <= i && i <= b[j])
        if (gender[j] == 'F')
          ++f;
        else
          ++m;
    ans = max(ans, min(f, m) * 2);
  }
  cout << ans << '\n';
}
