import std.stdio;
import std.algorithm;

void main()
{
	int n;
	
	scanf("%d", &n);
	
	bool[] used = new bool[n];
	char[] gender = new char[n];
	int[] from = new int[n];
	int[] to = new int[n];
	
	for (int i = 0; i < n; i++) {
		char[10] s;
		scanf("%s%d%d", s.ptr, &from[i], &to[i]);
		gender[i] = s[0];
	}
	
	int res = 0;
	
	for (int i = 1; i <= 366; i++) {
		char[2] genders = ['F', 'M'];
		int[2] found = [0, 0];
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < n; k++) {
				if (!used[k] && gender[k] == genders[j] && from[k] <= i && to[k] >= i) {
					found[j]++;
				}
			}
		}
		
		res = max(res, min(found[0], found[1]));
	}
	
	printf("%d\n", 2 * res);
}
