#include <bits/stdc++.h>
using namespace std;
struct hoomanTime {
  int day;
  bool isMale, isEnd;
};
vector<hoomanTime> inp;
bool banding(hoomanTime a, hoomanTime b) {
  double tmp1, tmp2;
  tmp1 = a.day;
  tmp2 = b.day;
  if (a.isEnd) tmp1 += 0.5;
  if (b.isEnd) tmp2 += 0.5;
  return (tmp1 < tmp2);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    hoomanTime tmp1, tmp2;
    tmp1.isEnd = false;
    tmp2.isEnd = true;
    char c;
    cin >> c;
    if (c == 'M')
      tmp1.isMale = tmp2.isMale = true;
    else
      tmp1.isMale = tmp2.isMale = false;
    cin >> tmp1.day >> tmp2.day;
    inp.push_back(tmp1);
    inp.push_back(tmp2);
  }
  sort(inp.begin(), inp.end(), banding);
  int M, F;
  M = F = 0;
  int res = -1;
  int len = inp.size();
  for (int i = 0; i < len; i++) {
    if (!inp[i].isEnd) {
      if (inp[i].isMale)
        M++;
      else
        F++;
    } else {
      if (inp[i].isMale)
        M--;
      else
        F--;
    }
    res = max(res, min(F, M));
  }
  cout << res * 2 << endl;
}
