program tenquestionnine
 implicit none
 character(10**5) :: S
 character(7) :: T(4) = (/"dream  ","dreamer","erase  ","eraser "/)
 integer :: L(4) = (/5,7,5,6/)
 integer i, len
 read(*,*) S
 len=len_trim(S)
 a: do while (len.gt.0)
  do i=1,4
   if((trim(T(i))).eq.(S((len-L(i)+1):len))) then
   len = len - L(i)
   cycle a
   end if
  end do
  write(*,*) "NO"
  return
  end do a
  write(*,*) "YES"
end program
