object Main extends App {

  val es: Stream[String] = Stream("eraser", "erase", "dreamer", "dream")

  // @scala.annotation.tailrec
  def matchAll(s: String): Option[String] = s match {
    case _ if s.length == 0 => Some("")
    case _                  => {
      es.find(e => {
        if (s.slice(0, e.length) == e)
          matchAll(s.drop(e.length)) != None
        else
          false
      })
    }
  }

  val input: String = scala.io.StdIn.readLine // S

  if (matchAll(input) != None)
    println("YES")
  else
    println("NO")
}
