S = eval(input())

N = len(S)

R = S[::-1]

dic = ['maerd','remaerd','esare','resare']

i = 0

while i < N:

    for w in dic:

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

            i += len(w)

            break

    else:

        print('NO')

        exit()

print('YES')

S = eval(input())

S = S[::-1]

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

kws = [kw[::-1] for kw in kws]



i = 0

while i < len(S):

    for kw in kws:

        if S[i:i+len(kw)] == kw:

            i += len(kw)

            break

    else:

        print('NO')

        exit()

print('YES')

S = eval(input())
N = len(S)
R = S[::-1]
dic = ["maerd", "remaerd", "esare", "resare"]
i = 0
while i < N:
    for w in dic:
        if R[i:].startswith(w):
            i += len(w)
            break
    else:
        print("NO")
        exit()
print("YES")

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

-N = len(S) -R = S[::-1] -dic = ["maerd", "remaerd", "esare", "resare"] +S = S[::-1] +kws = ["dream", "dreamer", "erase", "eraser"] +kws = [kw[::-1] for kw in kws] -while i < N: -    for w in dic: -        if R[i:].startswith(w): -            i += len(w) +while i < len(S): +    for kw in kws: +        if S[i : i + len(kw)] == kw: +            i += len(kw)