PROGRAM-ID.                      ABC_044_B.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N       PIC 9(5).
    01 K       PIC 9(5).
    01 X       PIC 9(5).
    01 Y       PIC 9(5).
    01 minK    PIC 9(5).
    01 tmp     PIC 9(9).
    01 A       PIC 9(18).
    01 ans     PIC X(18).
    01 ZS      PIC Z(10).
    01 DUMMY   PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT N.
    ACCEPT K.
    ACCEPT X.
    ACCEPT Y.

    COMPUTE minK = FUNCTION MIN(N, K).
    COMPUTE tmp = X * minK + Y * (N - minK).

    MOVE tmp 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.
