public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int n = Integer . parseInt ( sc . next ( ) ) ;
  long k = Long . parseLong ( sc . next ( ) ) ;
  long [ ] A = new long [ n ] ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    A [ i ] = Long . parseLong ( sc . next ( ) ) ;
  }
  sc . close ( ) ;
  long res = 0 ;
  for ( int d = MAX_DIGIT ;
  d >= - 1 ;
  -- d ) {
    if ( d != - 1 && ! ( ( k & 1L << d ) != 0 ) ) continue ;
    long tmp = 0 ;
    for ( int e = MAX_DIGIT ;
    e >= 0 ;
    -- e ) {
      long mask = 1L << e ;
      int num = 0 ;
      for ( int i = 0 ;
      i < n ;
      ++ i ) if ( ( A [ i ] & mask ) != 0 ) ++ num ;
      if ( e > d ) {
        if ( ( k & mask ) != 0 ) tmp += mask * ( n - num ) ;
        else tmp += mask * num ;
      }
      else if ( e == d ) {
        tmp += mask * num ;
      }
      else {
        tmp += mask * Math . max ( num , n - num ) ;
      }
    }
    res = Math . max ( res , tmp ) ;
  }
  System . out . println ( res ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; long k = Long . parseLong ( sc . next ( ) ) ; long [ ] A = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { A [ i ] = Long . parseLong ( sc . next ( ) ) ; } sc . close ( ) ; long res = 0 ; for ( int d = MAX_DIGIT ; d >= - 1 ; -- d ) { if ( d != - 1 && ! ( ( k & 1L << d ) != 0 ) ) continue ; long tmp = 0 ; for ( int e = MAX_DIGIT ; e >= 0 ; -- e ) { long mask = 1L << e ; int num = 0 ; for ( int i = 0 ; i < n ; ++ i ) if ( ( A [ i ] & mask ) != 0 ) ++ num ; if ( e > d ) { if ( ( k & mask ) != 0 ) tmp += mask * ( n - num ) ; else tmp += mask * num ; } else if ( e == d ) { tmp += mask * num ; } else { tmp += mask * Math . max ( num , n - num ) ; } } res = Math . max ( res , tmp ) ; } System . out . println ( res ) ; }
(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)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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 (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 (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal))) right: (unary_expression operand: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) right: (decimal_integer_literal)))))) consequence: (continue_statement)) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (decimal_integer_literal) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) alternative: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier)))))))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))