defmodule Main do
  def main() do
    s = IO.gets("") |> String.trim()
    day_dream(s)
    |> IO.puts()
  end

  def day_dream(s) do
    cond do
      Regex.match?(~r/dream$/, s) -> day_dream(String.slice(s, 0..-6))
      Regex.match?(~r/dreamer$/, s) -> day_dream(String.slice(s, 0..-8))
      Regex.match?(~r/erase$/, s) -> day_dream(String.slice(s, 0..-6))
      Regex.match?(~r/eraser$/, s) -> day_dream(String.slice(s, 0..-7))
      s == "" -> "YES"
      true -> "NO"
    end
  end
end
