open Core

let s = Scanf.scanf "%s" ident

let rec solve s =
  if String.length s = 0 then true
  else
    match String.chop_suffix s "dream" with
    | Some sub ->
        solve sub
    | None -> (
      match String.chop_suffix s "dreamer" with
      | Some sub ->
          solve sub
      | None -> (
        match String.chop_suffix s "erase" with
        | Some sub ->
            solve sub
        | None -> (
          match String.chop_suffix s "eraser" with
          | Some sub ->
              solve sub
          | None ->
              false ) ) )

let str = if solve s then "YES\n" else "NO\n"

let () = print_endline str
