-module('Main').
-export([main/1]).

calc("maerd" ++ S) -> calc(S);
calc("remaerd" ++ S) -> calc(S);
calc("esare" ++ S) -> calc(S);
calc("resare" ++ S) -> calc(S);
calc([]) -> true;
calc(_) -> false.

solve() ->
    [S] = input("~s"),
    SRev = lists:reverse(S),
    io:format("~s~n", [case calc(SRev) of
        true -> "YES";
        false -> "NO"
    end]),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.
