IDENTIFICATION DIVISION.
PROGRAM-ID. 170A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(10).
01 TBL.
   03 X       PIC 9(1) OCCURS 5.
01 I          PIC 9(1).
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO X(1) X(2) X(3) X(4) X(5).
*>
  PERFORM VARYING I FROM 1 BY 1 UNTIL X(I) = 0
  END-PERFORM.
*>
  DISPLAY I.
  STOP RUN.
