#include <bits/stdc++.h>
using namespace std;
long long int arr[2][367] = {{0}};
int n, i, j;
char ch[2];
int a, b;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ch >> a >> b;
    for (j = a; j <= b; j++) {
      if (ch[0] == 'M')
        arr[0][j]++;
      else
        arr[1][j]++;
    }
  }
  int ans = 0;
  for (i = 0; i < 367; i++) {
    arr[0][i] = min(arr[0][i], arr[1][i]) * 2;
    if (arr[0][i] > ans) ans = arr[0][i];
  }
  cout << ans;
  return 0;
}
