IDENTIFICATION DIVISION.
PROGRAM-ID. 166B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(4000).
01 N          PIC 9(03).
01 K          PIC 9(03).
01 D          PIC 9(03).
01 TBL.
   03 D1      OCCURS 100.
      05 A    PIC 9(03).
01 I          PIC 9(01) COMP.
01 J          PIC 9(03) COMP.
01 X          PIC 9(03) COMP.
01 P1         PIC 9(04) COMP.
01 P2         PIC 9(04) COMP.
01 CNT        PIC 9(03).
01 OUT        PIC Z(2)9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO N K.
*>
  MOVE ZERO TO TBL.
  PERFORM VARYING J FROM 1 BY 1 UNTIL J > K
    ACCEPT D
    ACCEPT INP
    MOVE 1 TO P1
    PERFORM VARYING I FROM 1 BY 1 UNTIL I > D
      PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
      END-PERFORM
      MOVE INP(P1:P2 - P1) TO X
      ADD  1 TO A(X)
      COMPUTE P1 = P2 + 1
    END-PERFORM
  END-PERFORM.
*>
  MOVE ZERO TO CNT.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    IF (A(I) = 0) 
      ADD 1 TO CNT
    END-IF
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
