#include <bits/stdc++.h>
using namespace std;
const int MN = 5005;
struct Info
{
int t, l, r;
Info(){};
};
Info info[MN];
int main()
{
int n;
cin >> n;
for(int i = 0; i < n; ++i){
char c;
cin >> c >> info[i].l >> info[i].r;
if(c == 'M'){
info[i].t = 1;
}
}
int ans = 0;
for(int i = 1; i <= 366; ++i){
int f = 0;
int m = 0;
for(int j = 0; j < n; ++j){
if(info[j].l <= i && i <= info[j].r){
if(info[j].t){
++m;
}else{
++f;
}
}
}
ans = max(ans, min(f, m));
}
cout << ans * 2 << '\n';
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTU4gPSA1MDA1OwpzdHJ1Y3QgSW5mbwp7CglpbnQgdCwgbCwgcjsKCUluZm8oKXt9Owp9OwoKSW5mbyBpbmZvW01OXTsKaW50IG1haW4oKQp7CglpbnQgbjsKCWNpbiA+PiBuOwoJZm9yKGludCBpID0gMDsgaSA8IG47ICsraSl7CgkJY2hhciBjOwoJCWNpbiA+PiBjID4+IGluZm9baV0ubCA+PiBpbmZvW2ldLnI7CgkJaWYoYyA9PSAnTScpewoJCQlpbmZvW2ldLnQgPSAxOwoJCX0KCX0KCWludCBhbnMgPSAwOwoKCWZvcihpbnQgaSA9IDE7IGkgPD0gMzY2OyArK2kpewoJCWludCBmID0gMDsKCQlpbnQgbSA9IDA7CgkJZm9yKGludCBqID0gMDsgaiA8IG47ICsrail7CgkJCWlmKGluZm9bal0ubCA8PSBpICYmIGkgPD0gaW5mb1tqXS5yKXsKCQkJCWlmKGluZm9bal0udCl7CgkJCQkJKyttOwoJCQkJfWVsc2V7CgkJCQkJKytmOwoJCQkJfQoJCQl9CgkJfQoJCWFucyA9IG1heChhbnMsIG1pbihmLCBtKSk7Cgl9Cgljb3V0IDw8IGFucyAqIDIgPDwgJ1xuJzsKfQo=