暴力
#include <iostream>
int arr[2][367];
int main()
{
std::ios::sync_with_stdio(false);
int n, st, ed;
char sex;
std::cin >> n;
for (int i = 0; i != n; ++i)
{
std::cin >> sex >> st >> ed;
if (sex == 'F')
{
for (int i = st; i <= ed; ++i)
{
arr[0][i]++;
}
}
else
{
for (int i = st; i <= ed; ++i)
{
arr[1][i]++;
}
}
}
int res = 0;
for (int i = 1; i <= 367; ++i)
{
if (res <= 2 * std::min(arr[0][i], arr[1][i]))
res = 2 * std::min(arr[0][i], arr[1][i]);
}
std::cout << res << std::endl;
return 0;
}