a=("dream","erase");ans="YES"

s=eval(input())

while s!="":

  if s[-7:]=="dreamer":s=s[:-7]

  elif s[-6:]=="eraser":s=s[:-6]

  elif s[-5:]in a:s=s[:-5]

  else:ans="NO";break

print(ans)
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")

if s=="":print('YES')

else:print('NO')
a = ("dream", "erase")
ans = "YES"
s = eval(input())
while s != "":
    if s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-6:] == "eraser":
        s = s[:-6]
    elif s[-5:] in a:
        s = s[:-5]
    else:
        ans = "NO"
        break
print(ans)

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

-a = ("dream", "erase") -ans = "YES" -s = eval(input()) -while s != "": -    if s[-7:] == "dreamer": -        s = s[:-7] -    elif s[-6:] == "eraser": -        s = s[:-6] -    elif s[-5:] in a: -        s = s[:-5] -    else: -        ans = "NO" -        break -print(ans) +s = ( +    input() +    .replace("eraser", "") +    .replace("erase", "") +    .replace("dreamer", "") +    .replace("dream", "") +) +if s == "": +    print("YES") +else: +    print("NO")