public static int ans ( String g ) {
  int index0 = g . indexOf ( '[' ) ;
  int index1 = g . lastIndexOf ( ']' ) ;
  if ( index0 == - 1 || index1 == - 1 || index0 > index1 ) {
    return - 1 ;
  }
  int index2 = g . indexOf ( ':' , index0 ) ;
  int index3 = - 1 ;
  for ( int i = index1 ;
  i >= 0 ;
  i -- ) {
    if ( g . charAt ( i ) == ':' ) {
      index3 = i ;
      break ;
    }
  }
  if ( index2 == - 1 || index3 == - 1 || index2 >= index3 ) {
    return - 1 ;
  };
}

public static int ans ( String g ) { int index0 = g . indexOf ( ' [ ' ) ; int index1 = g . lastIndexOf ( ' ] ' ) ; if ( index0 == - 1 || index1 == - 1 || index0 > index1 ) { return - 1 ; } int index2 = g . indexOf ( ' : ' , index0 ) ; int index3 = - 1 ; for ( int i = index1 ; i >= 0 ; i -- ) { if ( g . charAt ( i ) == ' : ' ) { index3 = i ; break ; } } if ( index2 == - 1 || index3 == - 1 || index2 >= index3 ) { return - 1 ; } ; }
(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 (character_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (character_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (block (return_statement (unary_expression operand: (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (character_literal) (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (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 (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (break_statement))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (block (return_statement (unary_expression operand: (decimal_integer_literal)))))))