#include <bits/stdc++.h>
using namespace std;
int n;
int m[500], first[500], r, li;
int main() {
  char c;
  int a, b;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> c >> a >> b;
    li = max(li, b);
    if (c == 'F')
      for (int j = a; j <= b; ++j) ++first[j];
    else
      for (int j = a; j <= b; ++j) ++m[j];
  }
  for (int i = 1; i <= li; ++i) {
    m[i] = min(m[i], first[i]);
    r = max(r, m[i]);
  }
  cout << 2 * r << endl;
  return 0;
}
