S = eval(input())

S = S[::-1]

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



i = 0

while i < len(S):

    for word in words:

        if S[i:].startswith(word[::-1]):

            i += len(word)

            break

    else:

        print('NO')

        exit()

print('YES')
S = eval(input())

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

e = len(S)

while e:

    for w in ws:

        if S[e-len(w):e] == w:

            e -= len(w)

            break

    else:

        print('NO')

        exit()

print('YES')
S = eval(input())
S = S[::-1]
words = ["dream", "dreamer", "erase", "eraser"]
i = 0
while i < len(S):
    for word in words:
        if S[i:].startswith(word[::-1]):
            i += len(word)
            break
    else:
        print("NO")
        exit()
print("YES")

S = eval(input())
ws = ["dreamer", "eraser", "dream", "erase"]
e = len(S)
while e:
    for w in ws:
        if S[e - len(w) : e] == w:
            e -= len(w)
            break
    else:
        print("NO")
        exit()
print("YES")

-S = S[::-1] -words = ["dream", "dreamer", "erase", "eraser"] -i = 0 -while i < len(S): -    for word in words: -        if S[i:].startswith(word[::-1]): -            i += len(word) +ws = ["dreamer", "eraser", "dream", "erase"] +e = len(S) +while e: +    for w in ws: +        if S[e - len(w) : e] == w: +            e -= len(w)