public static void main ( String [ ] args ) {
  FastScanner input = new FastScanner ( ) ;
  int n = input . nextInt ( ) ;
  int male [ ] = new int [ 367 ] ;
  int female [ ] = new int [ 367 ] ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    char ch = input . next ( ) . charAt ( 0 ) ;
    int a = input . nextInt ( ) ;
    int b = input . nextInt ( ) ;
    if ( ch == 'M' ) {
      for ( int j = a ;
      j <= b ;
      j ++ ) {
        male [ j ] ++ ;
      }
    }
    else {
      for ( int j = a ;
      j <= b ;
      j ++ ) {
        female [ j ] ++ ;
      }
    }
  }
  int ans = Integer . MIN_VALUE ;
  for ( int i = 1 ;
  i < 367 ;
  i ++ ) {
    ans = Math . max ( ans , Math . min ( male [ i ] , female [ i ] ) ) ;
  }
  System . out . println ( ans * 2 ) ;
}

public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int male [ ] = new int [ 367 ] ; int female [ ] = new int [ 367 ] ; for ( int i = 0 ; i < n ; i ++ ) { char ch = input . next ( ) . charAt ( 0 ) ; int a = input . nextInt ( ) ; int b = input . nextInt ( ) ; if ( ch == ' M ' ) { for ( int j = a ; j <= b ; j ++ ) { male [ j ] ++ ; } } else { for ( int j = a ; j <= b ; j ++ ) { female [ j ] ++ ; } } } int ans = Integer . MIN_VALUE ; for ( int i = 1 ; i < 367 ; i ++ ) { ans = Math . max ( ans , Math . min ( male [ i ] , female [ i ] ) ) ; } System . out . println ( ans * 2 ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (identifier))))))) alternative: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (array_access array: (identifier) index: (identifier)))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))))