s = list(eval(input()))



while len(s) > 0:

    if ''.join(s[-7:]) == 'dreamer':

        del s[-7:]

    elif ''.join(s[-6:]) == 'eraser':

        del s[-6:]

    elif ''.join(s[-5:]) == 'dream' or ''.join(s[-5:]) == 'erase':

        del s[-5:]

    else:

        break

print(('YES' if len(s) == 0 else 'NO'))
S = list(eval(input()))

a = list('dream')

b = list('dreamer')

c = list('erase')

d = list('eraser')



while True:

    if S[-5:] == a:

        del S[-5:]

    elif S[-7:] == b:

        del S[-7:]

    elif S[-5:] == c:

        del S[-5:]

    elif S[-6:] == d:

        del S[-6:]

    else:

        break

        

if len(S) == 0:

    print('YES')

else:

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

S = list(eval(input()))
a = list("dream")
b = list("dreamer")
c = list("erase")
d = list("eraser")
while True:
    if S[-5:] == a:
        del S[-5:]
    elif S[-7:] == b:
        del S[-7:]
    elif S[-5:] == c:
        del S[-5:]
    elif S[-6:] == d:
        del S[-6:]
    else:
        break
if len(S) == 0:
    print("YES")
else:
    print("NO")

-s = list(eval(input())) -while len(s) > 0: -    if "".join(s[-7:]) == "dreamer": -        del s[-7:] -    elif "".join(s[-6:]) == "eraser": -        del s[-6:] -    elif "".join(s[-5:]) == "dream" or "".join(s[-5:]) == "erase": -        del s[-5:] +S = list(eval(input())) +a = list("dream") +b = list("dreamer") +c = list("erase") +d = list("eraser") +while True: +    if S[-5:] == a: +        del S[-5:] +    elif S[-7:] == b: +        del S[-7:] +    elif S[-5:] == c: +        del S[-5:] +    elif S[-6:] == d: +        del S[-6:] -print(("YES" if len(s) == 0 else "NO")) +if len(S) == 0: +    print("YES") +else: +    print("NO")