S = eval(input())

lst_str = ["maerd", "remaerd", "esare", "resare"]

char = ""



for c in S[::-1]:

    char += c

    if char in lst_str:

        char = ""

if char:

    print("NO")

else:

    print("YES")

S = eval(input())



char = S.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")

if char:

    print("NO")

else:

    print("YES")
S = eval(input())
lst_str = ["maerd", "remaerd", "esare", "resare"]
char = ""
for c in S[::-1]:
    char += c
    if char in lst_str:
        char = ""
if char:
    print("NO")
else:
    print("YES")

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

-lst_str = ["maerd", "remaerd", "esare", "resare"] -char = "" -for c in S[::-1]: -    char += c -    if char in lst_str: -        char = "" +char = ( +    S.replace("eraser", "") +    .replace("erase", "") +    .replace("dreamer", "") +    .replace("dream", "") +)