#include <bits/stdc++.h>
using namespace std;
int X[8] = {1, -1, 0, 0, 1, 1, -1, -1};
int Y[8] = {0, 0, 1, -1, 1, -1, 1, -1};
int N, M;
bool valid(int i, int j) {
  if (i >= 0 && j >= 0 && i < N && j < M) return true;
  return false;
}
const int maxn = 400;
pair<int, int> day[maxn];
int main() {
  ifstream fin("input.in");
  ofstream fout("output.out");
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    int a, b;
    cin >> c >> a >> b;
    for (int j = a; j <= b; j++) {
      if (c == 'F')
        day[j].first++;
      else
        day[j].second++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 366; i++)
    ans = max(ans, 2 * min(day[i].first, day[i].second));
  cout << ans;
  return 0;
}
