IDENTIFICATION DIVISION.
PROGRAM-ID. 163C.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
  SELECT STDIO ASSIGN TO KEYBOARD. 
*>
DATA DIVISION.
FILE SECTION.
FD STDIO.
01 INP        PIC X(700000).
*>
WORKING-STORAGE SECTION.
01 N          PIC 9(7) COMP.
01 I          PIC 9(6) COMP.
01 W          PIC 9(6) COMP.
01 P1         PIC 9(7) COMP.
01 P2         PIC 9(7) COMP.
01 TBL.
   03 A       PIC 9(6) OCCURS 200000.
01 OUT        PIC Z(5)9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
*>
  OPEN INPUT STDIO.
  READ STDIO.         
  CLOSE STDIO.
*>
  MOVE ZERO TO TBL.
  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 W
    ADD 1 TO A(W)
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    MOVE A(I) TO OUT
    DISPLAY FUNCTION TRIM(OUT)
  END-PERFORM.
*>
  STOP RUN.
