public static void main ( String [ ] args ) {
  int n = 0 ;
  int k = 0 ;
  try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) {
    String [ ] tmp = br . readLine ( ) . split ( "\\s" ) ;
    n = Integer . parseInt ( tmp [ 0 ] ) ;
    k = Integer . parseInt ( tmp [ 1 ] ) ;
  }
  catch ( IOException e ) {
    e . printStackTrace ( ) ;
    System . exit ( 1 ) ;
  }
  long quotient = k ;
  quotient *= ( long ) Math . pow ( k - 1 , n - 1 ) ;
  System . out . print ( quotient ) ;
}

public static void main ( String [ ] args ) { int n = 0 ; int k = 0 ; try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String [ ] tmp = br . readLine ( ) . split ( " \\ s " ) ; n = Integer . parseInt ( tmp [ 0 ] ) ; k = Integer . parseInt ( tmp [ 1 ] ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } long quotient = k ; quotient *= ( long ) Math . pow ( k - 1 , n - 1 ) ; System . out . print ( quotient ) ; }
(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: (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))) (try_with_resources_statement resources: (resource_specification (resource type: (type_identifier) name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) body: (block (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal))))))) (catch_clause (catch_formal_parameter (catch_type (type_identifier)) name: (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))