private static int solve ( Scanner scanner ) {
  int N = Integer . parseInt ( scanner . nextLine ( ) ) ;
  int [ ] nums = lineToIntNums ( scanner . nextLine ( ) ) ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    nums [ i ] -- ;
  }
  int ret = 0 ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    if ( nums [ i ] == i ) {
      if ( i == N - 1 ) {
        swap ( i - 1 , i , nums ) ;
      }
      else {
        swap ( i , i + 1 , nums ) ;
      }
      ret ++ ;
    }
  }
  return ret ;
}

private static int solve ( Scanner scanner ) { int N = Integer . parseInt ( scanner . nextLine ( ) ) ; int [ ] nums = lineToIntNums ( scanner . nextLine ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { nums [ i ] -- ; } int ret = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( nums [ i ] == i ) { if ( i == N - 1 ) { swap ( i - 1 , i , nums ) ; } else { swap ( i , i + 1 , nums ) ; } ret ++ ; } } return ret ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (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: (method_invocation name: (identifier) arguments: (argument_list (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: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (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: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier))))) alternative: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier)))))) (expression_statement (update_expression (identifier))))))) (return_statement (identifier))))