public static void main ( String [ ] args ) {
  FastScanner input = new FastScanner ( ) ;
  int store [ ] = new int [ 100001 ] ;
  long i = 1 ;
  long value = 0 ;
  while ( value < 100001 ) {
    value = ( long ) ( ( Math . pow ( 2 , i ) - 1 ) * ( Math . pow ( 2 , i - 1 ) ) ) ;
    if ( value < 100001 ) store [ ( int ) value ] = 1 ;
    i ++ ;
  }
  TreeSet < Integer > set = new TreeSet < > ( Collections . reverseOrder ( ) ) ;
  int n = input . nextInt ( ) ;
  for ( int j = 1 ;
  j <= Math . sqrt ( n ) ;
  j ++ ) {
    if ( n % j == 0 ) {
      set . add ( j ) ;
      if ( n / j != j ) {
        set . add ( n / j ) ;
      }
    }
  }
  for ( Integer integer : set ) {
    if ( store [ integer ] == 1 ) {
      System . out . println ( integer ) ;
      return ;
    }
  }
}

public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; int store [ ] = new int [ 100001 ] ; long i = 1 ; long value = 0 ; while ( value < 100001 ) { value = ( long ) ( ( Math . pow ( 2 , i ) - 1 ) * ( Math . pow ( 2 , i - 1 ) ) ) ; if ( value < 100001 ) store [ ( int ) value ] = 1 ; i ++ ; } TreeSet < Integer > set = new TreeSet < > ( Collections . reverseOrder ( ) ) ; int n = input . nextInt ( ) ; for ( int j = 1 ; j <= Math . sqrt ( n ) ; j ++ ) { if ( n % j == 0 ) { set . add ( j ) ; if ( n / j != j ) { set . add ( n / j ) ; } } } for ( Integer integer : set ) { if ( store [ integer ] == 1 ) { System . out . println ( integer ) ; return ; } } }
(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) 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) value: (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 (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) right: (decimal_integer_literal))) right: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (cast_expression type: (integral_type) value: (identifier))) right: (decimal_integer_literal)))) (expression_statement (update_expression (identifier))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) 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)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))))))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (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 (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) (return_statement)))))))