#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> b[5001];     for (int i = 0; i < n; i++) {       string s;       int a, b1, c;       cin >> s >> a >> b1;       if (s[0] ==  M )         c = 0;       else         c = 1;       b[i].push_back(c);       b[i].push_back(a);       b[i].push_back(b1);     }     int ans = 0;     for (int i = 1; i <= 366; i++) {       int m[2] = {};       for (int j = 0; j < n; j++) {         if (b[j][1] <= i && b[j][2] >= i) m[b[j][0]]++;       }       ans = max(ans, 2 * min(m[0], m[1]));     }     cout << ans;     return 0;   }   