S = eval(input())



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



flag = True

while flag:

    for fstr in fstrs:

        result = S.rfind(fstr)

        if result >= 0 and result == len(S) - len(fstr):

            # print('found: {} in {} ({})'.format(fstr, S, result))

            S = S[0:result]

            flag = True

            break

        else:

            # print('not found: {} in {}'.format(fstr, S))

            flag = False

    if len(S) == 0:

        break



if len(S) > 0:

    print('NO')

else:

    print('YES')

S = eval(input())



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



for i in range(len(strs)):

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



if len(S) > 0:

    print('NO')

else:

    print('YES')
S = eval(input())
fstrs = ["dreamer", "eraser", "dream", "erase"]
flag = True
while flag:
    for fstr in fstrs:
        result = S.rfind(fstr)
        if result >= 0 and result == len(S) - len(fstr):
            # print('found: {} in {} ({})'.format(fstr, S, result))
            S = S[0:result]
            flag = True
            break
        else:
            # print('not found: {} in {}'.format(fstr, S))
            flag = False
    if len(S) == 0:
        break
if len(S) > 0:
    print("NO")
else:
    print("YES")

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

-fstrs = ["dreamer", "eraser", "dream", "erase"] -flag = True -while flag: -    for fstr in fstrs: -        result = S.rfind(fstr) -        if result >= 0 and result == len(S) - len(fstr): -            # print('found: {} in {} ({})'.format(fstr, S, result)) -            S = S[0:result] -            flag = True -            break -        else: -            # print('not found: {} in {}'.format(fstr, S)) -            flag = False -    if len(S) == 0: -        break +strs = ["eraser", "erase", "dreamer", "dream"] +for i in range(len(strs)): +    S = S.replace(strs[i], "")