import re

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

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

    print("NO")

else:

    print("YES")
import re

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

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

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