IDENTIFICATION DIVISION.
PROGRAM-ID. 135B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP PIC X(150).
01 N   PIC 9(2).
01 I   PIC 9(2).
01 WR  PIC 9(2).
01 P   PIC 9(2).
01 P1  PIC 9(3).
01 P2  PIC 9(3).
*>
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT INP.
*>
  MOVE 0 TO WR.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM UNTIL INP(P1:1) NOT = ' '
      ADD 1 TO P1
    END-PERFORM
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
*>
    MOVE INP(P1:P2 - P1) TO P
    IF (P NOT = I)
      ADD 1 TO WR
    END-IF
*>
    MOVE P2 TO P1
  END-PERFORM.
*>
  IF (WR <= 2)
    DISPLAY 'YES'
  ELSE 
    DISPLAY 'NO'
  END-IF.
*>
  STOP RUN.
