s = eval(input())

while True:

    if s[-7:] == 'dreamer':

        s = s[:-7]

    elif s[-6:] == 'eraser':

        s = s[:-6]

    elif s[-5:] == 'dream':

        s = s[:-5]

    elif s[-5:] == 'erase':

        s = s[:-5]

    else:

        print('NO')

        break



    if len(s) == 0:

        print('YES')

        break

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

s = eval(input())



for x in target:

    s = s.replace(x, "")



if s == "":

    print("YES")

else:

    print("NO")
s = eval(input())
while True:
    if s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-6:] == "eraser":
        s = s[:-6]
    elif s[-5:] == "dream":
        s = s[:-5]
    elif s[-5:] == "erase":
        s = s[:-5]
    else:
        print("NO")
        break
    if len(s) == 0:
        print("YES")
        break

target = ["eraser", "erase", "dreamer", "dream"]
s = eval(input())
for x in target:
    s = s.replace(x, "")
if s == "":
    print("YES")
else:
    print("NO")

+target = ["eraser", "erase", "dreamer", "dream"] -while True: -    if s[-7:] == "dreamer": -        s = s[:-7] -    elif s[-6:] == "eraser": -        s = s[:-6] -    elif s[-5:] == "dream": -        s = s[:-5] -    elif s[-5:] == "erase": -        s = s[:-5] -    else: -        print("NO") -        break -    if len(s) == 0: -        print("YES") -        break +for x in target: +    s = s.replace(x, "") +if s == "": +    print("YES") +else: +    print("NO")