       IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X(110000).
       01 NOW PIC 999999.
       01 temp PIC 9.
       PROCEDURE DIVISION.
       MAIN.
      	ACCEPT INP.
      	PERFORM VARYING NOW FROM 1 BY 1 UNTIL INP(NOW:1) = SPACE
      	END-PERFORM.
      	ADD -1 TO NOW.
      	PERFORM VARYING NOW FROM NOW BY -1 UNTIL NOW <= 0
      		IF INP(NOW:1) = 'm' THEN
      			IF NOW <= 4 THEN
      				DISPLAY "NO"
      				STOP RUN
      			END-IF
      			SUBTRACT 4 FROM NOW
      			IF INP(NOW:5) NOT = "dream" THEN
      				DISPLAY "NO"
      				STOP RUN
      			END-IF
      		ELSE IF INP(NOW:1) = 'e' THEN
      			IF NOW <= 4 THEN
      				DISPLAY "NO"
      				STOP RUN
      			END-IF
      			SUBTRACT 4 FROM NOW
      			IF INP(NOW:5) NOT = "erase" THEN
      				DISPLAY "NO"
      				STOP RUN
      			END-IF
      		ELSE IF INP(NOW:1) = 'r' THEN
      			IF NOW <= 1 THEN
      				DISPLAY "NO"
      			END-IF
      			SUBTRACT 1 FROM NOW
      			IF INP(NOW:1) = 'e' THEN
      				IF NOW <= 1 THEN
      					DISPLAY "NO"
      				END-IF
					SUBTRACT 1 FROM NOW
      				IF INP(NOW:1) = 'm' THEN
      					IF NOW <= 4 THEN
      						DISPLAY "NO"
      					END-IF
      					SUBTRACT 4 FROM NOW
      				IF INP(NOW:7) NOT = "dreamer" THEN
      						DISPLAY "NO"
      						STOP RUN
      					END-IF
      				ELSE IF INP(NOW:1) = 's'
      					IF NOW <= 3 THEN
      						DISPLAY "NO"
      					END-IF
      					SUBTRACT 3 FROM NOW
      				IF INP(NOW:6) NOT = "eraser" THEN
      						DISPLAY "NO"
      						STOP RUN
      					END-IF
      				END-IF
      			ELSE
      				DISPLAY "NO"
      				STOP RUN
      			END-IF
      		ELSE
      			DISPLAY "NO"
      			STOP RUN
      		END-IF
      	END-PERFORM.
      	DISPLAY "YES"
      	STOP RUN.
      
