def word_break(s, words):

    ok = [True]

    word_length = max(len(word) for word in words)

    for i in range(1, len(s) + 1):

        ok += any(ok[j] and s[j:i] in words for j in range(max(0, i - word_length), i)),

    return ok[-1]





s = eval(input())

words = {"eraser", "erase", "dreamer", "dream"}

print(("YES" if word_break(s, words) else "NO"))
s = eval(input())

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

    print("NO")

else:

    print("YES")
def word_break(s, words):
    ok = [True]
    word_length = max(len(word) for word in words)
    for i in range(1, len(s) + 1):
        ok += (
            any(ok[j] and s[j:i] in words for j in range(max(0, i - word_length), i)),
        )
    return ok[-1]


s = eval(input())
words = {"eraser", "erase", "dreamer", "dream"}
print(("YES" if word_break(s, words) else "NO"))

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

-def word_break(s, words): -    ok = [True] -    word_length = max(len(word) for word in words) -    for i in range(1, len(s) + 1): -        ok += ( -            any(ok[j] and s[j:i] in words for j in range(max(0, i - word_length), i)), -        ) -    return ok[-1] - - -words = {"eraser", "erase", "dreamer", "dream"} -print(("YES" if word_break(s, words) else "NO")) +if ( +    s.replace("eraser", "") +    .replace("erase", "") +    .replace("dreamer", "") +    .replace("dream", "") +): +    print("NO") +else: +    print("YES")