module RegExp : sig
  type t
  val empty_set : t
  val empty_str : t
  val char : char -> t
  val app : t -> t -> t
  val union : t -> t -> t
  val star : t -> t

  val matches : char list -> t -> bool
end = struct
  type t = { sort : sort; match_eps : bool; derive : char -> t }
  and sort = EmptySet | EmptyStr | Other

  let rec empty_set =
    { sort = EmptySet;
      match_eps = false;
      derive = fun _ -> empty_set }

  let empty_str =
    { sort = EmptyStr;
      match_eps = true;
      derive = fun _ -> empty_set }

  let char c =
    { sort = Other;
      match_eps = false;
      derive = fun c' -> if c = c' then empty_str else empty_set }

  let rec union re1 re2 =
    match re1, re2 with
    | { sort = EmptySet }, _ -> re2
    | _, { sort = EmptySet } -> re1
    | _, _ ->
        { sort = Other;
          match_eps = re1.match_eps || re2.match_eps;
          derive = fun c -> union (re1.derive c) (re2.derive c) }

  let rec app re1 re2 =
    match re1 with
    | { sort = EmptyStr } -> re2
    | { sort = EmptySet } -> empty_set
    | _ ->
        { sort = Other;
          match_eps = re1.match_eps && re2.match_eps;
          derive = fun c ->
            union
              (app (re1.derive c) re2)
              (if re1.match_eps then re2.derive c else empty_set) }
  let app re1 = function
    | { sort = EmptyStr } -> re1
    | { sort = EmptySet } -> empty_set
    | re2 -> app re1 re2

  let star = function
    | { sort = EmptySet }
    | { sort = EmptyStr } -> empty_str
    | re0 ->
        let rec re =
          { sort = Other;
            match_eps = true;
            derive = fun c -> app (re0.derive c) re } in re

  let matches s re =
    (List.fold_left (fun re -> re.derive) re s).match_eps
end

let () =
  let s = read_line () in
  print_endline @@
  if
    let open RegExp in
    matches
      (* ((dream(er)?)|(erase(r)?))* *)
      (Array.to_list @@ Array.init (String.length s) @@ String.get s) @@
      star @@
        union
          (app (char 'd') @@ app (char 'r') @@ app (char 'e') @@ app (char 'a') @@ app (char 'm') @@
            union empty_str @@ app (char 'e') @@ char 'r')
          (app (char 'e') @@ app (char 'r') @@ app (char 'a') @@ app (char 's') @@ app (char 'e') @@
            (union empty_str @@ char 'r'))
  then "YES"
  else "NO"