public static void main ( String [ ] args ) {
  Scanner in = new Scanner ( System . in ) ;
  n = in . nextInt ( ) ;
  c = in . nextInt ( ) ;
  S = new int [ n ] ;
  T = new int [ n ] ;
  C = new int [ n ] ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    S [ i ] = in . nextInt ( ) ;
    T [ i ] = in . nextInt ( ) ;
    C [ i ] = in . nextInt ( ) ;
  }
  int [ ] memo = new int [ 200005 ] ;
  int [ ] counts = new int [ 200005 ] ;
  for ( int j = 1 ;
  j <= c ;
  j ++ ) {
    Arrays . fill ( memo , 0 ) ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      if ( j == C [ i ] ) {
        int si = S [ i ] ;
        int ti = T [ i ] ;
        memo [ 2 * si - 1 ] ++ ;
        memo [ 2 * ti ] -- ;
      }
    }
    for ( int i = 1 ;
    i < 200005 ;
    i ++ ) {
      memo [ i ] += memo [ i - 1 ] ;
    }
    for ( int i = 0 ;
    i < 200005 ;
    i ++ ) {
      if ( memo [ i ] > 0 ) {
        counts [ i ] ++ ;
      }
    }
  }
  int ans = Arrays . stream ( counts ) . max ( ) . getAsInt ( ) ;
  print ( ans ) ;
}

public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; n = in . nextInt ( ) ; c = in . nextInt ( ) ; S = new int [ n ] ; T = new int [ n ] ; C = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { S [ i ] = in . nextInt ( ) ; T [ i ] = in . nextInt ( ) ; C [ i ] = in . nextInt ( ) ; } int [ ] memo = new int [ 200005 ] ; int [ ] counts = new int [ 200005 ] ; for ( int j = 1 ; j <= c ; j ++ ) { Arrays . fill ( memo , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( j == C [ i ] ) { int si = S [ i ] ; int ti = T [ i ] ; memo [ 2 * si - 1 ] ++ ; memo [ 2 * ti ] -- ; } } for ( int i = 1 ; i < 200005 ; i ++ ) { memo [ i ] += memo [ i - 1 ] ; } for ( int i = 0 ; i < 200005 ; i ++ ) { if ( memo [ i ] > 0 ) { counts [ i ] ++ ; } } } int ans = Arrays . stream ( counts ) . max ( ) . getAsInt ( ) ; print ( ans ) ; }
(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 (field_access object: (identifier) field: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (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: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) 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 (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (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 (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (decimal_integer_literal))))) (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (decimal_integer_literal) right: (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: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier))))))