s=input().replace("eraser",",").replace("erase",",").replace("dreamer",",").replace("dream",",").replace(",","")

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

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

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

-    .replace("eraser", ",") -    .replace("erase", ",") -    .replace("dreamer", ",") -    .replace("dream", ",") -    .replace(",", "") +    .replace("eraser", "") +    .replace("erase", "") +    .replace("dreamer", "") +    .replace("dream", "")