IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_083_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(10).
    01 N      PIC 9(5).
    01 A      PIC 9(2).
    01 B      PIC 9(2).

    01 sm     PIC 9(10).

    01 num    PIC 9(3).

    01 i      PIC 9(5).

    01 X      PIC 9(5).
    01 R      PIC 9(5).

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

    01 ans    PIC X(10).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO N A B.

    MOVE 0 TO sm.
    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        MOVE i TO X
        MOVE 0 TO num
        PERFORM UNTIL X <= 0
            DIVIDE 10 INTO X GIVING X REMAINDER R
            ADD R TO num
        END-PERFORM

        IF A <= num AND num <= B THEN
           ADD i TO sm
        END-IF
    END-PERFORM.

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