s=input()[::-1]

while 0<len(s):

    if s[:5] in "maerd":

        s=s[5:]

    elif s[:5] in "esare":

        s=s[5:]

    elif s[:6] in "resare":

        s=s[6:]

    elif s[:7] in "remaerd":

        s=s[7:]

    else:

        print("NO")

        exit()

print("YES")

import re

s=input()

print("YES") if re.match("^(dream|dreamer|erase|eraser)+$",s) else print("NO")

s = input()[::-1]
while 0 < len(s):
    if s[:5] in "maerd":
        s = s[5:]
    elif s[:5] in "esare":
        s = s[5:]
    elif s[:6] in "resare":
        s = s[6:]
    elif s[:7] in "remaerd":
        s = s[7:]
    else:
        print("NO")
        exit()
print("YES")

import re

s = input()
print("YES") if re.match("^(dream|dreamer|erase|eraser)+$", s) else print("NO")

-s = input()[::-1] -while 0 < len(s): -    if s[:5] in "maerd": -        s = s[5:] -    elif s[:5] in "esare": -        s = s[5:] -    elif s[:6] in "resare": -        s = s[6:] -    elif s[:7] in "remaerd": -        s = s[7:] -    else: -        print("NO") -        exit() -print("YES") +import re + +s = input() +print("YES") if re.match("^(dream|dreamer|erase|eraser)+$", s) else print("NO")