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

for i in range(4):

    A[i] = A[i][::-1]



S = input()[::-1]

idx = 0

while idx < len(S):

    flag = False

    for i in range(4):

        if len(S) - idx < len(A[i]):

            continue

        else:

            if S[idx:idx+len(A[i])] == A[i]:

                flag = True

                idx += len(A[i])

                break

            else:

                continue

    if idx >= len(S) or flag == False:

        break



print((["NO","YES"][idx == len(S)]))
A = ['dream', 'dreamer', 'erase', 'eraser']



for i in range(len(A)):

    A[i] = A[i][::-1]



s = input()[::-1]

i = 0

while True:

    f = True

    for a in A:

        if len(a) > len(s) - i:

            continue

        if s[i:i+len(a)] == a:

            i += len(a)

            f = False

            break

    else:

        if i == len(s):

            print('YES')

            exit()

        if f == True:

            print('NO')

            exit()





print('YES')
A = ["dream", "dreamer", "erase", "eraser"]
for i in range(4):
    A[i] = A[i][::-1]
S = input()[::-1]
idx = 0
while idx < len(S):
    flag = False
    for i in range(4):
        if len(S) - idx < len(A[i]):
            continue
        else:
            if S[idx : idx + len(A[i])] == A[i]:
                flag = True
                idx += len(A[i])
                break
            else:
                continue
    if idx >= len(S) or flag == False:
        break
print((["NO", "YES"][idx == len(S)]))

A = ["dream", "dreamer", "erase", "eraser"]
for i in range(len(A)):
    A[i] = A[i][::-1]
s = input()[::-1]
i = 0
while True:
    f = True
    for a in A:
        if len(a) > len(s) - i:
            continue
        if s[i : i + len(a)] == a:
            i += len(a)
            f = False
            break
    else:
        if i == len(s):
            print("YES")
            exit()
        if f == True:
            print("NO")
            exit()
print("YES")

-for i in range(4): +for i in range(len(A)): -S = input()[::-1] -idx = 0 -while idx < len(S): -    flag = False -    for i in range(4): -        if len(S) - idx < len(A[i]): +s = input()[::-1] +i = 0 +while True: +    f = True +    for a in A: +        if len(a) > len(s) - i: -        else: -            if S[idx : idx + len(A[i])] == A[i]: -                flag = True -                idx += len(A[i]) -                break -            else: -                continue -    if idx >= len(S) or flag == False: -        break -print((["NO", "YES"][idx == len(S)])) +        if s[i : i + len(a)] == a: +            i += len(a) +            f = False +            break +    else: +        if i == len(s): +            print("YES") +            exit() +        if f == True: +            print("NO") +            exit() +print("YES")