static int Juzu ( int n , String s ) {
  if ( n % 2 == 0 ) return - 1 ;
  if ( n == 1 ) {
    if ( s . equals ( "b" ) ) return 0 ;
    else return - 1 ;
  }
  if ( s . charAt ( 0 ) == 'b' ) {
    for ( int i = 0 ;
    i < n - 2 ;
    i += 3 ) {
      if ( ! s . substring ( i , i + 3 ) . equals ( "bca" ) ) return - 1 ;
    }
    if ( s . charAt ( n - 1 ) == 'b' ) return n / 2 ;
  }
  if ( s . charAt ( 0 ) == 'a' ) {
    for ( int i = 0 ;
    i < n - 2 ;
    i += 3 ) {
      if ( ! s . substring ( i , i + 3 ) . equals ( "abc" ) ) return - 1 ;
    }
    if ( s . charAt ( n - 1 ) == 'c' ) return n / 2 ;
  }
  if ( s . charAt ( 0 ) == 'c' ) {
    for ( int i = 0 ;
    i < n - 2 ;
    i += 3 ) {
      if ( ! s . substring ( i , i + 3 ) . equals ( "cab" ) ) return - 1 ;
    }
    if ( s . charAt ( n - 1 ) == 'a' && s . charAt ( n - 2 ) == 'c' ) return n / 2 ;
  }
  return - 1 ;
}

static int Juzu ( int n , String s ) { if ( n % 2 == 0 ) return - 1 ; if ( n == 1 ) { if ( s . equals ( " b " ) ) return 0 ; else return - 1 ; } if ( s . charAt ( 0 ) == ' b ' ) { for ( int i = 0 ; i < n - 2 ; i += 3 ) { if ( ! s . substring ( i , i + 3 ) . equals ( " bca " ) ) return - 1 ; } if ( s . charAt ( n - 1 ) == ' b ' ) return n / 2 ; } if ( s . charAt ( 0 ) == ' a ' ) { for ( int i = 0 ; i < n - 2 ; i += 3 ) { if ( ! s . substring ( i , i + 3 ) . equals ( " abc " ) ) return - 1 ; } if ( s . charAt ( n - 1 ) == ' c ' ) return n / 2 ; } if ( s . charAt ( 0 ) == ' c ' ) { for ( int i = 0 ; i < n - 2 ; i += 3 ) { if ( ! s . substring ( i , i + 3 ) . equals ( " cab " ) ) return - 1 ; } if ( s . charAt ( n - 1 ) == ' a ' && s . charAt ( n - 2 ) == ' c ' ) return n / 2 ; } return - 1 ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (type_identifier) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (return_statement (decimal_integer_literal)) alternative: (return_statement (unary_expression operand: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal))) consequence: (return_statement (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal))) consequence: (return_statement (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (return_statement (unary_expression operand: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_literal)))) consequence: (return_statement (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (unary_expression operand: (decimal_integer_literal)))))