s = eval(input())

ans = 'YES'

 

while len(s) > 0:

    if s.endswith('dreamer'):

        s = s[:-7]

    elif s.endswith('dream'):

        s = s[:-5]

    elif s.endswith('eraser'):

        s = s[:-6]

    elif s.endswith('erase'):

        s = s[:-5]

    else:

        ans = 'NO'

        break

 

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

s = s[-1::-1]

word = ['resare','esare','remaerd','maerd',]

for i in word:

    s = s.replace(i,'')

if s:

    print('NO')

else:

    print('YES')
s = eval(input())
ans = "YES"
while len(s) > 0:
    if s.endswith("dreamer"):
        s = s[:-7]
    elif s.endswith("dream"):
        s = s[:-5]
    elif s.endswith("eraser"):
        s = s[:-6]
    elif s.endswith("erase"):
        s = s[:-5]
    else:
        ans = "NO"
        break
print(ans)

s = eval(input())
s = s[-1::-1]
word = [
    "resare",
    "esare",
    "remaerd",
    "maerd",
]
for i in word:
    s = s.replace(i, "")
if s:
    print("NO")
else:
    print("YES")

-ans = "YES" -while len(s) > 0: -    if s.endswith("dreamer"): -        s = s[:-7] -    elif s.endswith("dream"): -        s = s[:-5] -    elif s.endswith("eraser"): -        s = s[:-6] -    elif s.endswith("erase"): -        s = s[:-5] -    else: -        ans = "NO" -        break -print(ans) +s = s[-1::-1] +word = [ +    "resare", +    "esare", +    "remaerd", +    "maerd", +] +for i in word: +    s = s.replace(i, "") +if s: +    print("NO") +else: +    print("YES")