static void MinimumSwapOperations ( String s ) {
  boolean zero_exist = false ;
  boolean multiple_of_2 = false ;
  int sum = 0 ;
  int index_of_zero = 0 ;
  boolean more_zero = false ;
  for ( int i = 0 ;
  i < s . length ( ) ;
  i ++ ) {
    int val = s . charAt ( i ) - '0' ;
    if ( zero_exist == true ) more_zero = true ;
    if ( val == 0 ) {
      zero_exist = true ;
      index_of_zero = i ;
    }
    sum += val ;
  }
  if ( zero_exist == false || sum % 3 != 0 ) {
    System . out . println ( "-1" ) ;
    return ;
  }
  for ( int i = 0 ;
  i < s . length ( ) ;
  i ++ ) {
    int val = s . charAt ( i ) - '0' ;
    if ( val % 2 == 0 && i != index_of_zero ) multiple_of_2 = true ;
  }
  if ( multiple_of_2 == false ) {
    System . out . println ( "-1" ) ;
    return ;
  }
  int last_val = s . charAt ( s . length ( ) - 1 ) - '0' ;
  int second_last_val = s . charAt ( s . length ( ) - 2 ) - '0' ;
  if ( last_val == 0 && second_last_val % 2 == 0 ) System . out . println ( 0 ) ;
  else if ( ( last_val == 0 && second_last_val % 2 != 0 ) || ( last_val % 2 == 0 && second_last_val == 0 ) ) System . out . println ( 1 ) ;
  else if ( more_zero == true && ( last_val == 0 && second_last_val % 2 != 0 ) ) System . out . println ( 1 ) ;
  else System . out . println ( 2 ) ;
}

static void MinimumSwapOperations ( String s ) { boolean zero_exist = false ; boolean multiple_of_2 = false ; int sum = 0 ; int index_of_zero = 0 ; boolean more_zero = false ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int val = s . charAt ( i ) - '0' ; if ( zero_exist == true ) more_zero = true ; if ( val == 0 ) { zero_exist = true ; index_of_zero = i ; } sum += val ; } if ( zero_exist == false || sum % 3 != 0 ) { System . out . println ( " - 1" ) ; return ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int val = s . charAt ( i ) - '0' ; if ( val % 2 == 0 && i != index_of_zero ) multiple_of_2 = true ; } if ( multiple_of_2 == false ) { System . out . println ( " - 1" ) ; return ; } int last_val = s . charAt ( s . length ( ) - 1 ) - '0' ; int second_last_val = s . charAt ( s . length ( ) - 2 ) - '0' ; if ( last_val == 0 && second_last_val % 2 == 0 ) System . out . println ( 0 ) ; else if ( ( last_val == 0 && second_last_val % 2 != 0 ) || ( last_val % 2 == 0 && second_last_val == 0 ) ) System . out . println ( 1 ) ; else if ( more_zero == true && ( last_val == 0 && second_last_val % 2 != 0 ) ) System . out . println ( 1 ) ; else System . out . println ( 2 ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (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))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (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))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (true))) consequence: (expression_statement (assignment_expression left: (identifier) right: (true)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (true))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (false)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (return_statement))) (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))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (true)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (false))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (return_statement))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) right: (character_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) right: (character_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) right: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (true)) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal)))))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal)))))))))