IDENTIFICATION DIVISION.
PROGRAM-ID. 146B.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
  SELECT STDIO ASSIGN TO KEYBOARD. 
*>
DATA DIVISION.
FILE SECTION.
FD STDIO.
01 INP   PIC X(10000).
*>
WORKING-STORAGE SECTION.
01 S       PIC X(10000).
01 S-LEN   PIC 9(5).
01 N       PIC 9(5).
01 A-TBL.
   03 F1   PIC X(26) VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
   03 F2   PIC X(26) VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
01 A-TBL-R REDEFINES A-TBL.
   03 A-CH PIC X(1) OCCURS 52.
01 C-TBL.
   03 C-CD PIC S9(4) COMP OCCURS 256.
01 C-WK.
   03 C1   PIC X(1) VALUE LOW-VALUE.
   03 C2   PIC X(1).
01 C-WK-R  REDEFINES C-Wk.
   03 ACD  PIC S9(4) COMP. 
01 I     PIC 9(5).
01 OUT   PIC ZZZZ9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
  OPEN INPUT STDIO.
  READ STDIO.
  CLOSE STDIO.
  UNSTRING INP DELIMITED BY ' '
     INTO S COUNT S-LEN.
*>
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > 26
    MOVE A-CH(I) TO C2
    MOVE I     TO C-CD(ACD)  
  END-PERFORM.
*>
  IF (N > 0)
    PERFORM VARYING I FROM 1 BY 1 UNTIL I > S-LEN
      MOVE S(I:1)              TO C2    
      MOVE A-CH(C-CD(ACD) + N) TO S(I:1) 
    END-PERFORM
  END-IF.
*>
  DISPLAY S(1:S-LEN).
  STOP RUN.
