import re

s = eval(input())

print(("YES" if re.match("^(eraser?|dream(er)?)*$", s) else "NO"))
s = eval(input())

if s.replace("eraser"," ").replace("erase"," ").replace("dreamer"," ").replace("dream"," ").replace(" ", ""):

    print("NO")

else:

    print("YES")
import re

s = eval(input())
print(("YES" if re.match("^(eraser?|dream(er)?)*$", s) else "NO"))

s = eval(input())
if (
    s.replace("eraser", " ")
    .replace("erase", " ")
    .replace("dreamer", " ")
    .replace("dream", " ")
    .replace(" ", "")
):
    print("NO")
else:
    print("YES")

-import re - -print(("YES" if re.match("^(eraser?|dream(er)?)*$", s) else "NO")) +if ( +    s.replace("eraser", " ") +    .replace("erase", " ") +    .replace("dreamer", " ") +    .replace("dream", " ") +    .replace(" ", "") +): +    print("NO") +else: +    print("YES")