S = eval(input())

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



id = len(S)

while(id > 0):

    if S[:id].endswith("dream"):

        id -= 5

    elif S[:id].endswith("dreamer"):

        id -= 7

    elif S[:id].endswith("erase"):

        id -= 5

    elif S[:id].endswith("eraser"):

        id -= 6

    else:

        print("NO")

        exit(0)

print("YES")

S = eval(input())



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

R = len(S)

while(R > 0):

    for i in range(4):

        if R >= len(s[i]):

            if S[R-len(s[i]):R] == s[i]:

                R -= len(s[i])

                break

        if i == 3:

            print("NO")

            exit(0)

print("YES")

S = eval(input())
words = ["dream", "dreamer", "erase", "eraser"]
id = len(S)
while id > 0:
    if S[:id].endswith("dream"):
        id -= 5
    elif S[:id].endswith("dreamer"):
        id -= 7
    elif S[:id].endswith("erase"):
        id -= 5
    elif S[:id].endswith("eraser"):
        id -= 6
    else:
        print("NO")
        exit(0)
print("YES")

S = eval(input())
s = ["dream", "dreamer", "erase", "eraser"]
R = len(S)
while R > 0:
    for i in range(4):
        if R >= len(s[i]):
            if S[R - len(s[i]) : R] == s[i]:
                R -= len(s[i])
                break
        if i == 3:
            print("NO")
            exit(0)
print("YES")

-words = ["dream", "dreamer", "erase", "eraser"] -id = len(S) -while id > 0: -    if S[:id].endswith("dream"): -        id -= 5 -    elif S[:id].endswith("dreamer"): -        id -= 7 -    elif S[:id].endswith("erase"): -        id -= 5 -    elif S[:id].endswith("eraser"): -        id -= 6 -    else: -        print("NO") -        exit(0) +s = ["dream", "dreamer", "erase", "eraser"] +R = len(S) +while R > 0: +    for i in range(4): +        if R >= len(s[i]): +            if S[R - len(s[i]) : R] == s[i]: +                R -= len(s[i]) +                break +        if i == 3: +            print("NO") +            exit(0)