s = eval(input())

for i in range(len(s) // 5):

    if s[-5:] == "dream" or s[-5:] == "erase":

        s = s[:-5]

    elif s[-6:] == "eraser":

        s = s[:-6]

    elif s[-7:] == "dreamer":

        s = s[:-7]

ans = "YES" if s == "" else "NO"

print(ans)
s = eval(input())

str_list = ["eraser","erase","dreamer","dream"]

for e in str_list:

    s = s.replace(e,"")

ans = "YES" if s == "" else "NO"

print(ans)
s = eval(input())
for i in range(len(s) // 5):
    if s[-5:] == "dream" or s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    elif s[-7:] == "dreamer":
        s = s[:-7]
ans = "YES" if s == "" else "NO"
print(ans)

s = eval(input())
str_list = ["eraser", "erase", "dreamer", "dream"]
for e in str_list:
    s = s.replace(e, "")
ans = "YES" if s == "" else "NO"
print(ans)

-for i in range(len(s) // 5): -    if s[-5:] == "dream" or s[-5:] == "erase": -        s = s[:-5] -    elif s[-6:] == "eraser": -        s = s[:-6] -    elif s[-7:] == "dreamer": -        s = s[:-7] +str_list = ["eraser", "erase", "dreamer", "dream"] +for e in str_list: +    s = s.replace(e, "")