IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_078_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(20).
    01 X      PIC 9(6).
    01 Y      PIC 9(6).
    01 Z      PIC 9(6).
    01 D      PIC 9(6).
    01 R      PIC 9(6).
    01 ans    PIC X(18).

    01 ZS     PIC Z(6)9.
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO X Y Z.

*>  A * Y + (A + 1) * Z <= X
*>  A <= (X - Z) / (Y + Z)

    SUBTRACT Z FROM X.
    ADD Y TO Z.
    DIVIDE Z INTO X GIVING D REMAINDER R.

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