You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
S=input()
i=0
j=0
k=len(S)
while(1):
    if(i==k):
        print("yes")
        break
    if(i==j):
        print("No")
        break
    j=i
    if(S[i:i+5]=="dream" or S[i:i+5]=="erase"):
        i+=5
    if(S[i:i+6]=="eraser"):
        i+=6
    if(S[i:i+7]=="dreamer"):
        i+=7
s=input()
S=s[::-1]
i=0
j=0
k=len(S)
while(1):
    if(i==k):
        print("YES")
        break
    if(S[i:i+5]=="maerd" or S[i:i+5]=="esare"):
        i+=5
    if(S[i:i+6]=="resare"):
        i+=6
    if(S[i:i+7]=="remaerd"):
        i+=7
    if(i==j):
        print("NO")
        break
    j=i