S=eval(input())

dp=[False]*(len(S)+1)

dp[0]=True

for i in range(len(S)):

    if i>=4 and S[i-4:i+1]=="dream":

        dp[i+1]|=dp[i-4]

    if i>=4 and S[i-4:i+1]=="erase":

        dp[i+1]|=dp[i-4]

    if i>=6 and S[i-6:i+1]=="dreamer":

        dp[i+1]|=dp[i-6]

    if i>=5 and S[i-5:i+1]=="eraser":

        dp[i+1]|=dp[i-5]

print(("YES" if dp[len(S)] else "NO"))
import sys

S="".join(reversed(eval(input())))

i=0

while i<len(S):

    if i+4<len(S) and (S[i:i+5]=="maerd" or S[i:i+5]=="esare"):

        i+=5

    elif i+5<len(S) and (S[i:i+6]=="resare"):

        i+=6

    elif i+6<len(S) and (S[i:i+7]=="remaerd"):

        i+=7

    else:

        print("NO")

        sys.exit()

print("YES")
S = eval(input())
dp = [False] * (len(S) + 1)
dp[0] = True
for i in range(len(S)):
    if i >= 4 and S[i - 4 : i + 1] == "dream":
        dp[i + 1] |= dp[i - 4]
    if i >= 4 and S[i - 4 : i + 1] == "erase":
        dp[i + 1] |= dp[i - 4]
    if i >= 6 and S[i - 6 : i + 1] == "dreamer":
        dp[i + 1] |= dp[i - 6]
    if i >= 5 and S[i - 5 : i + 1] == "eraser":
        dp[i + 1] |= dp[i - 5]
print(("YES" if dp[len(S)] else "NO"))

import sys

S = "".join(reversed(eval(input())))
i = 0
while i < len(S):
    if i + 4 < len(S) and (S[i : i + 5] == "maerd" or S[i : i + 5] == "esare"):
        i += 5
    elif i + 5 < len(S) and (S[i : i + 6] == "resare"):
        i += 6
    elif i + 6 < len(S) and (S[i : i + 7] == "remaerd"):
        i += 7
    else:
        print("NO")
        sys.exit()
print("YES")

-S = eval(input()) -dp = [False] * (len(S) + 1) -dp[0] = True -for i in range(len(S)): -    if i >= 4 and S[i - 4 : i + 1] == "dream": -        dp[i + 1] |= dp[i - 4] -    if i >= 4 and S[i - 4 : i + 1] == "erase": -        dp[i + 1] |= dp[i - 4] -    if i >= 6 and S[i - 6 : i + 1] == "dreamer": -        dp[i + 1] |= dp[i - 6] -    if i >= 5 and S[i - 5 : i + 1] == "eraser": -        dp[i + 1] |= dp[i - 5] -print(("YES" if dp[len(S)] else "NO")) +import sys + +S = "".join(reversed(eval(input()))) +i = 0 +while i < len(S): +    if i + 4 < len(S) and (S[i : i + 5] == "maerd" or S[i : i + 5] == "esare"): +        i += 5 +    elif i + 5 < len(S) and (S[i : i + 6] == "resare"): +        i += 6 +    elif i + 6 < len(S) and (S[i : i + 7] == "remaerd"): +        i += 7 +    else: +        print("NO") +        sys.exit() +print("YES")