s=input()[::-1]

for i in range(10**5):

  if s[:5]=="maerd":

    s=s[5:]

  elif s[:7]=="remaerd":

    s=s[7:]

  elif s[:5]=="esare":

    s=s[5:]

  elif s[:6]=="resare":

    s=s[6:]

  elif s=="":

    print("YES")

    break

  else:

    print("NO")

    break
import re

s = eval(input())

if re.fullmatch(r"(dream|dreamer|erase|eraser)+",s):

  print("YES")

else:

  print("NO")
s = input()[::-1]
for i in range(10**5):
    if s[:5] == "maerd":
        s = s[5:]
    elif s[:7] == "remaerd":
        s = s[7:]
    elif s[:5] == "esare":
        s = s[5:]
    elif s[:6] == "resare":
        s = s[6:]
    elif s == "":
        print("YES")
        break
    else:
        print("NO")
        break

import re

s = eval(input())
if re.fullmatch(r"(dream|dreamer|erase|eraser)+", s):
    print("YES")
else:
    print("NO")

-s = input()[::-1] -for i in range(10**5): -    if s[:5] == "maerd": -        s = s[5:] -    elif s[:7] == "remaerd": -        s = s[7:] -    elif s[:5] == "esare": -        s = s[5:] -    elif s[:6] == "resare": -        s = s[6:] -    elif s == "": -        print("YES") -        break -    else: -        print("NO") -        break +import re + +s = eval(input()) +if re.fullmatch(r"(dream|dreamer|erase|eraser)+", s): +    print("YES") +else: +    print("NO")