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()
s = s.replace("eraser", "X")
s = s.replace("dreamer", "X")
s = s.replace("erase", "X")
s = s.replace("dream", "X")

count = s.count("X")
if len(s) == count:
    print("Yes")
else:
    print("No")
s = input()
s = s.replace("eraser", "X")
s = s.replace("erase", "X")
s = s.replace("dreamer", "X")
s = s.replace("dream", "X")
 
count = s.count("X")
if len(s) == count:
    print("YES")
else:
    print("NO")