IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
   SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD SYSIN.
   01 INDATA  PIC X(10000).
WORKING-STORAGE SECTION.
01 N          PIC 9(10).
01 S          PIC X(10000).
01 alp        PIC X(26) VALUE "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
01 cnt        PIC 9(10) VALUE 26.
01 i          PIC 9(10) COMP.
01 j          PIC 9(10) COMP.
01 f          PIC X(26).
01 t          PIC X(26).
01 ans        PIC X(10000).

PROCEDURE DIVISION.
  ACCEPT N.
  OPEN INPUT SYSIN.
  READ SYSIN INTO INDATA.
  CLOSE SYSIN.
  MOVE INDATA TO S.
  MOVE alp TO f.
  STRING alp(N + 1 : cnt - N) alp(1 : N) INTO t.
  PERFORM TRAN.
  DISPLAY FUNCTION TRIM(ans).
  STOP RUN.

TRAN SECTION.
  PERFORM VARYING i FROM 1 BY 1 UNTIL FUNCTION STORED-CHAR-LENGTH(S) < i
    PERFORM VARYING j FROM 1 BY 1 UNTIL cnt < j
      IF S(i : 1) = f(j : 1)
        EXIT PERFORM
      END-IF
    END-PERFORM
    MOVE t(j : 1) TO ans(i : 1)
  END-PERFORM.
