S = input()[::-1]

T = list(['maerd', 'remaerd', 'esare', 'resare'])

while(1):

    if len(S) == 0:

        print('YES')

        break

    elif S[:5] in T:

        S = S[5:]

    elif S[:6] in T:

        S = S[6:]

    elif S[:7] in T:

        S = S[7:]

    else:

        print('NO')

        break

S = eval(input())

T = list(['eraser', 'erase', 'dreamer', 'dream', ])

for i in range(4):

    S = S.replace(T[i], '')

if S == '':

    print('YES')

else:

    print('NO')
S = input()[::-1]
T = list(["maerd", "remaerd", "esare", "resare"])
while 1:
    if len(S) == 0:
        print("YES")
        break
    elif S[:5] in T:
        S = S[5:]
    elif S[:6] in T:
        S = S[6:]
    elif S[:7] in T:
        S = S[7:]
    else:
        print("NO")
        break

S = eval(input())
T = list(
    [
        "eraser",
        "erase",
        "dreamer",
        "dream",
    ]
)
for i in range(4):
    S = S.replace(T[i], "")
if S == "":
    print("YES")
else:
    print("NO")

-S = input()[::-1] -T = list(["maerd", "remaerd", "esare", "resare"]) -while 1: -    if len(S) == 0: -        print("YES") -        break -    elif S[:5] in T: -        S = S[5:] -    elif S[:6] in T: -        S = S[6:] -    elif S[:7] in T: -        S = S[7:] -    else: -        print("NO") -        break +S = eval(input()) +T = list( +    [ +        "eraser", +        "erase", +        "dreamer", +        "dream", +    ] +) +for i in range(4): +    S = S.replace(T[i], "") +if S == "": +    print("YES") +else: +    print("NO")