#include <bits/stdc++.h>
using namespace std;
stack<char> st;
map<string, int> mp;
queue<int> qq, qq1;
set<double> set1, set2;
pair<int, int> sup[1000];
char c;
long long n, x, y, m[5000], f[5000];
int main() {
  cin >> n;
  while (n--) {
    cin >> c >> x >> y;
    if (c == 'M')
      for (int j = x; j <= y; j++) m[j]++;
    else
      for (int j = x; j <= y; j++) f[j]++;
  }
  for (int i = 1; i <= 366; i++)
    if (min(m[i], f[i]) > m[0]) m[0] = min(m[i], f[i]);
  cout << 2 * m[0];
}
