#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, M = 1e6 + 5;
long long mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
long long infll = 1e18 + 7;
long long n, ans;
char a[N];
long long b[N], c[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (long long kek = 1; kek <= 366; kek++) {
    long long x = 0, y = 0;
    for (long long i = 1; i <= n; i++) {
      if (b[i] <= kek && kek <= c[i]) {
        if (a[i] == 'F')
          x++;
        else
          y++;
      }
    }
    ans = max(ans, min(x, y));
  }
  cout << 2 * ans;
}
