public void solve() throws IOException {
    int n = nextInt();
    int[] male = new int[366];
    int[] female = new int[366];
    for (int i = 0; i < n; i++) {
      boolean isMale = nextToken().equals("M");
      int start = nextInt();
      int end = nextInt();
      for (int j = start; j <= end; j++) {
        if (isMale) {
          male[j - 1]++;
        } else {
          female[j - 1]++;
        }
      }
    }
    int max = 0;
    for (int i = 0; i < 366; i++) {
      max = Math.max(max, Math.min(female[i], male[i]));
    }
    out.println(max * 2);
  }