#include <bits/stdc++.h>
const int N = 400;
int a[N], b[N];
char C;
int n, x, y, ans = 0;
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> C >> x >> y;
    if (C == 'F')
      for (int j = x; j <= y; j++) a[j]++;
    else
      for (int j = x; j <= y; j++) b[j]++;
  }
  for (int i = 1; i <= 366; i++) ans = max(ans, min(a[i], b[i]));
  cout << ans * 2 << endl;
}
