object Main extends App {

  f(io.StdIn.readLine().reverse.toList)

  def f(s: List[Char]): Unit = {
    if (s.isEmpty) {
      println("YES")
      sys.exit
    }
    s match {
      case List('m', 'a', 'e', 'r', 'd', x @ _*) => f(x.toList)
      case List('r', 'e', 'm', 'e', 'r', 'd', x @ _*) => f(x.toList)
      case List('e', 's', 'a', 'r', 'e', x @ _*) => f(x.toList)
      case List('r', 'e', 's', 'a', 'r', 'e', x @ _*) => f(x.toList)
      case _ => {
        println("NO")
        sys.exit
      }
    }
  }
}