IDENTIFICATION DIVISION.
PROGRAM-ID. 159B.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S          PIC X(100).
01 CNT        PIC 9(3).
01 E2         PIC 9(3).
01 S3         PIC 9(3).
01 P1         PIC 9(3).
01 P2         PIC 9(3).
01 OUT        PIC X(3).
*>
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT S.
  UNSTRING S DELIMITED BY ' '
      INTO S COUNT CNT. 
*>
  COMPUTE E2 = (CNT - 1) / 2.
  COMPUTE S3 = (CNT + 3) / 2.
*>
  MOVE 'Yes' TO OUT.
  MOVE   1 TO P1
  MOVE CNT TO P2
  PERFORM UNTIL (P1 >= P2) OR (OUT = 'No')
    IF (S(P1:1) NOT = S(P2:1))
      MOVE 'No' To OUT
    END-IF
    ADD      1 TO   P1
    SUBTRACT 1 FROM P2
  END-PERFORM.
*>
  MOVE 1  TO P1.
  MOVE E2 TO P2.
  PERFORM UNTIL (P1 >= P2) OR (OUT = 'No')
    IF (S(P1:1) NOT = S(P2:1))
      MOVE 'No' To OUT
    END-IF
    ADD      1 TO   P1
    SUBTRACT 1 FROM P2
  END-PERFORM.
*>
  MOVE S3  TO P1.
  MOVE CNT TO P2.
  PERFORM UNTIL (P1 >= P2) OR (OUT = 'No')
    IF (S(P1:1) NOT = S(P2:1))
      MOVE 'No' To OUT
    END-IF
    ADD      1 TO   P1
    SUBTRACT 1 FROM P2
  END-PERFORM.
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
