S = eval(input())

words = ['dreameraser','dreamerase','dreamer','dream','eraser','erase']

i = 0

while i < len(S):

    update = False

    for w in words:

        if S[i:].startswith(w):

            i += len(w)

            update =True

            break

    if not update:

        break

print(('YES' if i == len(S) else 'NO'))
S = eval(input())

words = ['dreamer','dream','eraser','erase']

i = len(S)

while i>0:

    update = False

    for w in words:

        if S[:i].endswith(w):

            i -= len(w)

            update =True

            break

    if not update:

        break

print(('YES' if i == 0 else 'NO'))
S = eval(input())
words = ["dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"]
i = 0
while i < len(S):
    update = False
    for w in words:
        if S[i:].startswith(w):
            i += len(w)
            update = True
            break
    if not update:
        break
print(("YES" if i == len(S) else "NO"))

S = eval(input())
words = ["dreamer", "dream", "eraser", "erase"]
i = len(S)
while i > 0:
    update = False
    for w in words:
        if S[:i].endswith(w):
            i -= len(w)
            update = True
            break
    if not update:
        break
print(("YES" if i == 0 else "NO"))

-words = ["dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"] -i = 0 -while i < len(S): +words = ["dreamer", "dream", "eraser", "erase"] +i = len(S) +while i > 0: -        if S[i:].startswith(w): -            i += len(w) +        if S[:i].endswith(w): +            i -= len(w) -print(("YES" if i == len(S) else "NO")) +print(("YES" if i == 0 else "NO"))