#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
template <typename T>
void chmin(T& a, const T& b) {
  if (b < a) a = b;
}
int N;
pair<int, int> day[370];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = (0); i < (N); i++) {
    char c;
    int x, y;
    cin >> c >> x >> y;
    if (c == 'M') {
      day[x].first++;
      day[y + 1].first--;
    }
    if (c == 'F') {
      day[x].second++;
      day[y + 1].second--;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++) {
    day[i].first += day[i - 1].first;
    day[i].second += day[i - 1].second;
    chmax(ans, min(day[i].first, day[i].second) * 2);
  }
  cout << ans << endl;
  return 0;
}
