PROGRAM-ID.                      ABC_046_B.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(9).
    01 N       PIC 9(4).
    01 K       PIC 9(4).
    01 total   PIC 9(10).
    01 ans     PIC X(10).

    01 ZS      PIC Z(11).
    01 DUMMY   PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO N K.

    MOVE 1 TO total.

    COMPUTE total = K * (K - 1) ** (N - 1)

    MOVE total TO ZS
    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.
