s = eval(input()) + "ZZZZZZZZZZZZZ"



i = 0

ans = "NO"



while(True):



 if s[i:i+5]=="dream":

  if s[i+5]=="d" or s[i+5]=="Z" or s[i+5:i+8]=="era":

   i += 5

  elif s[i+5:i+8]=="erd" or s[i+5:i+8]=="ere" or s[i+5:i+8]=="erZ":

   i += 7

  else:

   break

 

 elif s[i:i+5]=="erase":

  if s[i+5]=="d" or s[i+5]=="e" or s[i+5]=="Z":

   i += 5

  elif s[i+5]=="r":

   i += 6

  else:

   break



 elif s[i]=="Z":

  ans = "YES"

  break



 else:

  break



print(ans)
s = eval(input())

revs = s[::-1] + "Z"

i = 0



while(True):

 if revs[i:i+5]=="maerd": i+=5

 elif revs[i:i+7]=="remaerd": i+=7

 elif revs[i:i+5]=="esare": i+=5

 elif revs[i:i+6]=="resare": i+=6

 elif revs[i]=="Z":

  print("YES")

  break

 else:

  print("NO")

  break
s = eval(input()) + "ZZZZZZZZZZZZZ"
i = 0
ans = "NO"
while True:
    if s[i : i + 5] == "dream":
        if s[i + 5] == "d" or s[i + 5] == "Z" or s[i + 5 : i + 8] == "era":
            i += 5
        elif (
            s[i + 5 : i + 8] == "erd"
            or s[i + 5 : i + 8] == "ere"
            or s[i + 5 : i + 8] == "erZ"
        ):
            i += 7
        else:
            break
    elif s[i : i + 5] == "erase":
        if s[i + 5] == "d" or s[i + 5] == "e" or s[i + 5] == "Z":
            i += 5
        elif s[i + 5] == "r":
            i += 6
        else:
            break
    elif s[i] == "Z":
        ans = "YES"
        break
    else:
        break
print(ans)

s = eval(input())
revs = s[::-1] + "Z"
i = 0
while True:
    if revs[i : i + 5] == "maerd":
        i += 5
    elif revs[i : i + 7] == "remaerd":
        i += 7
    elif revs[i : i + 5] == "esare":
        i += 5
    elif revs[i : i + 6] == "resare":
        i += 6
    elif revs[i] == "Z":
        print("YES")
        break
    else:
        print("NO")
        break

-s = eval(input()) + "ZZZZZZZZZZZZZ" +s = eval(input()) +revs = s[::-1] + "Z" -ans = "NO" -    if s[i : i + 5] == "dream": -        if s[i + 5] == "d" or s[i + 5] == "Z" or s[i + 5 : i + 8] == "era": -            i += 5 -        elif ( -            s[i + 5 : i + 8] == "erd" -            or s[i + 5 : i + 8] == "ere" -            or s[i + 5 : i + 8] == "erZ" -        ): -            i += 7 -        else: -            break -    elif s[i : i + 5] == "erase": -        if s[i + 5] == "d" or s[i + 5] == "e" or s[i + 5] == "Z": -            i += 5 -        elif s[i + 5] == "r": -            i += 6 -        else: -            break -    elif s[i] == "Z": -        ans = "YES" +    if revs[i : i + 5] == "maerd": +        i += 5 +    elif revs[i : i + 7] == "remaerd": +        i += 7 +    elif revs[i : i + 5] == "esare": +        i += 5 +    elif revs[i : i + 6] == "resare": +        i += 6 +    elif revs[i] == "Z": +        print("YES") +        print("NO") -print(ans)