s = eval(input())

s=s[::-1] #文字列の反転

words = ["maerd", "remaerd", "esare", "resare"]

while len(s) > 4:

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

        s = s[5:]

        continue

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

        s = s[7:]

        continue

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

        s = s[5:]

        continue

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

        s = s[6:]

        continue

    else:

        break

if len(s) > 0:

    print('NO')

else:

    print('YES')

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

if s:

    print("NO")

else:

    print("YES")
s = eval(input())
s = s[::-1]  # 文字列の反転
words = ["maerd", "remaerd", "esare", "resare"]
while len(s) > 4:
    if s[:5] == "maerd":
        s = s[5:]
        continue
    elif s[:7] == "remaerd":
        s = s[7:]
        continue
    elif s[:5] == "esare":
        s = s[5:]
        continue
    elif s[:6] == "resare":
        s = s[6:]
        continue
    else:
        break
if len(s) > 0:
    print("NO")
else:
    print("YES")

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

-s = eval(input()) -s = s[::-1]  # 文字列の反転 -words = ["maerd", "remaerd", "esare", "resare"] -while len(s) > 4: -    if s[:5] == "maerd": -        s = s[5:] -        continue -    elif s[:7] == "remaerd": -        s = s[7:] -        continue -    elif s[:5] == "esare": -        s = s[5:] -        continue -    elif s[:6] == "resare": -        s = s[6:] -        continue -    else: -        break -if len(s) > 0: +s = ( +    input() +    .replace("eraser", "") +    .replace("erase", "") +    .replace("dreamer", "") +    .replace("dream", "") +) +if s: