#include <bits/stdc++.h>
using namespace std;
pair<int, int> ar[370];
int main() {
  int n, start, end;
  cin >> n;
  char ch;
  for (int i = 0; i < n; i++) {
    cin >> ch >> start >> end;
    if (ch == 'M')
      for (int j = start; j <= end; j++) {
        ar[j].first++;
      }
    else
      for (int j = start; j <= end; j++) {
        ar[j].second++;
      }
  }
  int ans = 0;
  for (int i = 0; i < 369; i++) {
    end = min(ar[i].first, ar[i].second);
    if (ans < end) {
      ans = end;
    }
  }
  cout << ans * 2;
  return 0;
}
