S = eval(input())

sr = ''

for i in S:

    sr = i + sr

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

c = 0

while c == 0:

    c = 1

    for i in lista:

        

        if sr[0:len(i)] == i:

            sr = sr[len(i):]

            c = 0



if sr == '':

    print('YES')

else:

    print('NO')

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())
sr = ""
for i in S:
    sr = i + sr
lista = ["remaerd", "resare", "esare", "maerd"]
c = 0
while c == 0:
    c = 1
    for i in lista:
        if sr[0 : len(i)] == i:
            sr = sr[len(i) :]
            c = 0
if sr == "":
    print("YES")
else:
    print("NO")

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()) -sr = "" -for i in S: -    sr = i + sr -lista = ["remaerd", "resare", "esare", "maerd"] -c = 0 -while c == 0: -    c = 1 -    for i in lista: -        if sr[0 : len(i)] == i: -            sr = sr[len(i) :] -            c = 0 -if sr == "": +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: -else: -    print("NO")