       IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC045-B.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 SA PIC X(101) VALUE SPACE.
       77 SB PIC X(101) VALUE SPACE.
       77 SC PIC X(101) VALUE SPACE.
       77 SAI PIC 9(3) VALUE 1.
       77 SBI PIC 9(3) VALUE 1.
       77 SCI PIC 9(3) VALUE 1.
       77 PREC PIC X(1) VALUE "A".
       77 CURC PIC X(1).
       77 I PIC 9(3).

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
            ACCEPT SA FROM SYSIN.
            ACCEPT SB FROM SYSIN.
            ACCEPT SC FROM SYSIN.
            MOVE "a" TO PREC.
            PERFORM VARYING I FROM 1 BY 1 UNTIL 300 < I
               EVALUATE PREC
                   WHEN "a"
                       IF SA(SAI:1) = SPACE THEN
                           EXIT PERFORM
                       END-IF
                       MOVE SA(SAI:1) TO PREC
                       ADD 1 TO SAI
                   WHEN "b"
                       IF SB(SBI:1) = SPACE THEN
                           EXIT PERFORM
                       END-IF
                       MOVE SB(SBI:1) TO PREC
                       ADD 1 TO SBI
                   WHEN "c"
                       IF SC(SCI:1) = SPACE THEN
                           EXIT PERFORM
                       END-IF
                       MOVE SC(SCI:1) TO PREC
                       ADD 1 TO SCI
               END-EVALUATE
      *        *無限ループ防止用
               ADD 1 TO I
            END-PERFORM.
            DISPLAY FUNCTION UPPER-CASE (PREC)
            STOP RUN.
       END PROGRAM ABC045-B.
