S = input()

words = ("dream", "dreamer", "erase", "eraser")



for _ in range((len(S) + 4) // 5):

    for word in words:

        if S.endswith(word):

            S = S[: -len(word)]

print("NO") if S else print("YES")

S = input()

for w in ("eraser", "erase", "dreamer", "dream"):

    S = S.replace(w, "")

print("NO") if S else print("YES")

S = input()
words = ("dream", "dreamer", "erase", "eraser")
for _ in range((len(S) + 4) // 5):
    for word in words:
        if S.endswith(word):
            S = S[: -len(word)]
print("NO") if S else print("YES")

S = input()
for w in ("eraser", "erase", "dreamer", "dream"):
    S = S.replace(w, "")
print("NO") if S else print("YES")

-words = ("dream", "dreamer", "erase", "eraser") -for _ in range((len(S) + 4) // 5): -    for word in words: -        if S.endswith(word): -            S = S[: -len(word)] +for w in ("eraser", "erase", "dreamer", "dream"): +    S = S.replace(w, "")