#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
const double PI = 3.14159;
vector<long long> v;
long long n, m, k, t, ans, sum, r, l, b, c, d, female[400], male[400];
char z;
bool flag;
string s, a;
map<string, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> z >> l >> r;
    if (z == 'M') {
      male[l]++;
      male[r + 1]--;
    } else {
      female[l]++;
      female[r + 1]--;
    }
  }
  for (int i = 1; i <= 366; i++) {
    female[i] += female[i - 1];
    male[i] += male[i - 1];
  }
  for (int i = 1; i <= 366; i++) {
    ans = max(ans, min(male[i], female[i]) * 2);
  }
  cout << ans << endl;
  return 0;
}
