import re

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

if s:

    print("NO")

else:

    print("YES")

import re

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

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

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