       IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC043-B.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 INSTR PIC X(10).
       77 ANS PIC X(10) VALUE SPACE.
       77 I PIC 9(2).
       77 ANSI PIC 9(2).

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
            ACCEPT INSTR FROM SYSIN.
            PERFORM VARYING I FROM 1 BY 1
             UNTIL LENGTH OF INSTR < I
               EVALUATE INSTR(I:1)
                   WHEN "0"
                       STRING ANS  "0" DELIMITED BY SPACE
                        INTO ANS
                       END-STRING
                   WHEN "1"
                       STRING ANS  "1" DELIMITED BY SPACE
                        INTO ANS
                       END-STRING
                   WHEN "B"
                       MOVE FUNCTION STORED-CHAR-LENGTH (ANS) TO ANSI
                       IF ANSI = 0 THEN
                           CONTINUE
                       ELSE
                         MOVE SPACE TO ANS(ANSI:1)
                       END-IF
               END-EVALUATE
            END-PERFORM.
            DISPLAY ANS.
            STOP RUN.
       END PROGRAM ABC043-B.
