S = eval(input())

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



i = len(S)

while True:

    if i == 0:

        print('YES')

        exit()

    for tg in targets:

        if S[i - len(tg):i][::-1] == tg[::-1]:

            i -= len(tg)

            break

    else:

        print('NO')

        exit()

S = eval(input())

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



for tg in targets:

    S = S.replace(tg, '')



if len(S) == 0:

    print('YES')

else:

    print('NO')

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

S = eval(input())
targets = ["eraser", "erase", "dreamer", "dream"]
for tg in targets:
    S = S.replace(tg, "")
if len(S) == 0:
    print("YES")
else:
    print("NO")

-targets = ["dream", "dreamer", "erase", "eraser"] -i = len(S) -while True: -    if i == 0: -        print("YES") -        exit() -    for tg in targets: -        if S[i - len(tg) : i][::-1] == tg[::-1]: -            i -= len(tg) -            break -    else: -        print("NO") -        exit() +targets = ["eraser", "erase", "dreamer", "dream"] +for tg in targets: +    S = S.replace(tg, "") +if len(S) == 0: +    print("YES") +else: +    print("NO")