import re

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

if s:

    print("NO")

else:

    print("YES")
import re

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

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

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