IDENTIFICATION DIVISION.
PROGRAM-ID. 166C.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
  SELECT STDIO ASSIGN TO KEYBOARD. 
*>
DATA DIVISION.
FILE SECTION.
FD STDIO.
01 INP        PIC X(1100000).
*>
WORKING-STORAGE SECTION.
01 INW        PIC X(14).
01 N          PIC 9(06) COMP.
01 M          PIC 9(06) COMP.
01 A          PIC 9(06) COMP.
01 B          PIC 9(06) COMP.
01 TBL1.
   03 H       PIC 9(10) OCCURS 100000.
01 TBL2.
   03 HM      PIC 9(10) OCCURS 100000.
01 I          PIC 9(06) COMP.
01 J          PIC 9(06) COMP.
01 P1         PIC 9(07) COMP.
01 P2         PIC 9(07) COMP.
01 CNT        PIC 9(06).
01 OUT        PIC Z(5)9.
*>
PROCEDURE DIVISION.
  ACCEPT INW.
  UNSTRING INW DELIMITED BY ' '
      INTO N M.
*>
  OPEN INPUT STDIO.
  READ STDIO.
  CLOSE STDIO.
*>
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO H(I)
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  MOVE ZERO TO TBL2.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > M
    ACCEPT INW 
    UNSTRING INW DELIMITED BY ' '
        INTO A B
    IF (HM(A) < H(B))
      MOVE H(B) TO HM(A)
    END-IF
    IF (HM(B) < H(A))
      MOVE H(A) TO HM(B)
    END-IF 
  END-PERFORM.
*>
  MOVE 0 TO CNT.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    IF (H(I) > HM(I))
      ADD 1 TO CNT
    END-IF 
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
