public static void main ( String [ ] args ) {
  Scanner scan = new Scanner ( System . in ) ;
  long N = scan . nextLong ( ) ;
  int maxbit = - 1 ;
  long n = N ;
  while ( n > 0 ) {
    n /= 2 ;
    ++ maxbit ;
  }
  Deque < Integer > first = new ArrayDeque < > ( ) ;
  List < Integer > second = new ArrayList < > ( ) ;
  for ( int i = maxbit ;
  i > 0 ;
  -- i ) {
    first . addLast ( i ) ;
    second . add ( i ) ;
  }
  Deque < Integer > useNumber = new ArrayDeque < > ( ) ;
  for ( int i = bitcount ( N ) - 1 ;
  i > 0 ;
  -- i ) {
    useNumber . addLast ( maxbit + i ) ;
    first . addFirst ( maxbit + i ) ;
  }
  for ( int i = maxbit - 1 ;
  i >= 0 ;
  -- i ) {
    if ( ( ( N >> i ) & 1 ) == 1 ) {
      int inn = useNumber . removeFirst ( ) ;
      second . add ( second . indexOf ( i + 1 ) + 1 , inn ) ;
    }
  }
  List < Integer > ans = new ArrayList < > ( ) ;
  ans . add ( 100 ) ;
  while ( ! first . isEmpty ( ) ) {
    ans . add ( first . removeFirst ( ) ) ;
  }
  for ( int i : second ) ans . add ( i ) ;
  ans . add ( 100 ) ;
  System . out . println ( ans . size ( ) ) ;
  for ( int i : ans ) System . out . print ( i + " " ) ;
  System . out . println ( ) ;
}

public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long N = scan . nextLong ( ) ; int maxbit = - 1 ; long n = N ; while ( n > 0 ) { n /= 2 ; ++ maxbit ; } Deque < Integer > first = new ArrayDeque < > ( ) ; List < Integer > second = new ArrayList < > ( ) ; for ( int i = maxbit ; i > 0 ; -- i ) { first . addLast ( i ) ; second . add ( i ) ; } Deque < Integer > useNumber = new ArrayDeque < > ( ) ; for ( int i = bitcount ( N ) - 1 ; i > 0 ; -- i ) { useNumber . addLast ( maxbit + i ) ; first . addFirst ( maxbit + i ) ; } for ( int i = maxbit - 1 ; i >= 0 ; -- i ) { if ( ( ( N >> i ) & 1 ) == 1 ) { int inn = useNumber . removeFirst ( ) ; second . add ( second . indexOf ( i + 1 ) + 1 , inn ) ; } } List < Integer > ans = new ArrayList < > ( ) ; ans . add ( 100 ) ; while ( ! first . isEmpty ( ) ) { ans . add ( first . removeFirst ( ) ) ; } for ( int i : second ) ans . add ( i ) ; ans . add ( 100 ) ; System . out . println ( ans . size ( ) ) ; for ( int i : ans ) System . out . print ( i + " ▁ " ) ; System . out . println ( ) ; }
(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: (unary_expression operand: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (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)))) (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)))) (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 (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (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: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal)) (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)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (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))))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (string_literal)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list)))))