#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long binpow(long long a, long long b) {
  if (b == 0) return 1;
  long long res = binpow(a, b / 2);
  if (b % 2)
    return res * res * a;
  else
    return res * res;
}
vector<int> adj[200006];
bool vis[200006];
bool color[200006];
bool dfs(int x) {
  vis[x] = 1;
  for (int i = 0; i < adj[x].size(); i++) {
    if (!vis[adj[x][i]]) {
      color[adj[x][i]] = !color[x];
      if (!dfs(adj[x][i])) return false;
    } else if (color[adj[x][i]] == color[x]) {
      return false;
    }
  }
  return true;
}
bool check(int a, int b) {
  while (a != 0) {
    int x = a % 10;
    if (x == 7) return 1;
    a /= 10;
  }
  while (b != 0) {
    int xx = b % 10;
    if (xx == 7) return 1;
    b /= 10;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt;
  cin >> tt;
  vector<pair<pair<int, int>, char>> vv;
  int ewq = 0;
  while (tt--) {
    char c;
    int r, l;
    cin >> c >> l >> r;
    vv.push_back({{l, r}, c});
  }
  sort(vv.begin(), vv.end());
  int F = 0;
  int M = 0;
  for (int i = 1; i <= 366; i++) {
    F = 0;
    M = 0;
    for (int j = 0; j < vv.size(); j++) {
      if (i >= vv[j].first.first && i <= vv[j].first.second) {
        if (vv[j].second == 'F')
          F++;
        else
          M++;
      }
    }
    ewq = max(min(F, M), ewq);
  }
  cout << ewq * 2 << "\n";
  return 0;
}
