S = input()[::-1]

i = 0

ls = len(S)

accept = True



while ls > i:

    if S[i: i+5] == "maerd" or S[i: i+5] == "esare":

        i += 5

    elif S[i: i+6] == "resare":

        i += 6

    elif S[i: i+7] == "remaerd":

        i += 7

    else:

        accept = False

        break



if accept:

    print("YES")

else:

    print("NO")
S = eval(input())



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

if len(result) == 0:

    print("YES")

else:

    print("NO")
S = input()[::-1]
i = 0
ls = len(S)
accept = True
while ls > i:
    if S[i : i + 5] == "maerd" or S[i : i + 5] == "esare":
        i += 5
    elif S[i : i + 6] == "resare":
        i += 6
    elif S[i : i + 7] == "remaerd":
        i += 7
    else:
        accept = False
        break
if accept:
    print("YES")
else:
    print("NO")

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

-S = input()[::-1] -i = 0 -ls = len(S) -accept = True -while ls > i: -    if S[i : i + 5] == "maerd" or S[i : i + 5] == "esare": -        i += 5 -    elif S[i : i + 6] == "resare": -        i += 6 -    elif S[i : i + 7] == "remaerd": -        i += 7 -    else: -        accept = False -        break -if accept: +S = eval(input()) +result = ( +    S.replace("eraser", "") +    .replace("erase", "") +    .replace("dreamer", "") +    .replace("dream", "") +) +if len(result) == 0: