public static void main ( String [ ] args ) {
  Scanner scanner = new Scanner ( System . in ) ;
  int N = scanner . nextInt ( ) ;
  long K = scanner . nextLong ( ) ;
  int [ ] digits = new int [ 41 ] ;
  int t = 0 ;
  while ( K > 0 ) {
    if ( K % 2 == 1 ) digits [ t ] = 1 ;
    K /= 2 ;
    t ++ ;
  }
  int [ ] numOnes = new int [ 41 ] ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    long a = scanner . nextLong ( ) ;
    int j = 0 ;
    while ( a > 0 ) {
      if ( a % 2 == 1 ) numOnes [ j ] ++ ;
      a /= 2 ;
      j ++ ;
    }
  }
  long [ ] [ ] dp = new long [ 42 ] [ 2 ] ;
  for ( int i = 40 ;
  i >= 0 ;
  i -- ) {
    long d = 1L << i ;
    int ones = numOnes [ i ] ;
    int zeros = N - ones ;
    if ( digits [ i ] == 0 ) {
      dp [ i ] [ 0 ] = dp [ i + 1 ] [ 0 ] + d * ones ;
      if ( dp [ i + 1 ] [ 1 ] > 0 ) dp [ i ] [ 1 ] = dp [ i + 1 ] [ 1 ] + d * Math . max ( ones , zeros ) ;
    }
    else {
      dp [ i ] [ 0 ] = dp [ i + 1 ] [ 0 ] + d * zeros ;
      dp [ i ] [ 1 ] = dp [ i + 1 ] [ 0 ] + d * ones ;
      if ( dp [ i + 1 ] [ 1 ] > 0 ) dp [ i ] [ 1 ] = Math . max ( dp [ i ] [ 1 ] , dp [ i + 1 ] [ 1 ] + d * Math . max ( ones , zeros ) ) ;
    }
  }
  System . out . println ( Math . max ( dp [ 0 ] [ 0 ] , dp [ 0 ] [ 1 ] ) ) ;
}

public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; long K = scanner . nextLong ( ) ; int [ ] digits = new int [ 41 ] ; int t = 0 ; while ( K > 0 ) { if ( K % 2 == 1 ) digits [ t ] = 1 ; K /= 2 ; t ++ ; } int [ ] numOnes = new int [ 41 ] ; for ( int i = 0 ; i < N ; i ++ ) { long a = scanner . nextLong ( ) ; int j = 0 ; while ( a > 0 ) { if ( a % 2 == 1 ) numOnes [ j ] ++ ; a /= 2 ; j ++ ; } } long [ ] [ ] dp = new long [ 42 ] [ 2 ] ; for ( int i = 40 ; i >= 0 ; i -- ) { long d = 1L << i ; int ones = numOnes [ i ] ; int zeros = N - ones ; if ( digits [ i ] == 0 ) { dp [ i ] [ 0 ] = dp [ i + 1 ] [ 0 ] + d * ones ; if ( dp [ i + 1 ] [ 1 ] > 0 ) dp [ i ] [ 1 ] = dp [ i + 1 ] [ 1 ] + d * Math . max ( ones , zeros ) ; } else { dp [ i ] [ 0 ] = dp [ i + 1 ] [ 0 ] + d * zeros ; dp [ i ] [ 1 ] = dp [ i + 1 ] [ 0 ] + d * ones ; if ( dp [ i + 1 ] [ 1 ] > 0 ) dp [ i ] [ 1 ] = Math . max ( dp [ i ] [ 1 ] , dp [ i + 1 ] [ 1 ] + d * Math . max ( ones , zeros ) ) ; } } System . out . println ( Math . max ( dp [ 0 ] [ 0 ] , dp [ 0 ] [ 1 ] ) ) ; }
(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)))) (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: (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))))) (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 (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: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (update_expression (array_access array: (identifier) index: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))))))) (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)) 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: (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: (array_access array: (identifier) index: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))))) alternative: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (decimal_integer_literal)) right: (binary_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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (decimal_integer_literal)) (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (decimal_integer_literal)))))))))