s = eval(input())



while s:

    if s[:6] == "eraser":

        s = s[6:]

    elif s[:5] == "erase":

        s = s[5:]

    elif s[:5] == "dream":

        if s[5:8] == "era":

            s = s[5:]

        elif s[5:7] == "er":

            s = s[7:]

        else:

            s = s[5:]

    else:

        print("NO")

        exit()

print("YES")

s = eval(input())



if s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","") == "":

    print("YES")

else:

    print("NO")
s = eval(input())
while s:
    if s[:6] == "eraser":
        s = s[6:]
    elif s[:5] == "erase":
        s = s[5:]
    elif s[:5] == "dream":
        if s[5:8] == "era":
            s = s[5:]
        elif s[5:7] == "er":
            s = s[7:]
        else:
            s = s[5:]
    else:
        print("NO")
        exit()
print("YES")

s = eval(input())
if (
    s.replace("eraser", "")
    .replace("erase", "")
    .replace("dreamer", "")
    .replace("dream", "")
    == ""
):
    print("YES")
else:
    print("NO")

-while s: -    if s[:6] == "eraser": -        s = s[6:] -    elif s[:5] == "erase": -        s = s[5:] -    elif s[:5] == "dream": -        if s[5:8] == "era": -            s = s[5:] -        elif s[5:7] == "er": -            s = s[7:] -        else: -            s = s[5:] -    else: -        print("NO") -        exit() -print("YES") +if ( +    s.replace("eraser", "") +    .replace("erase", "") +    .replace("dreamer", "") +    .replace("dream", "") +    == "" +): +    print("YES") +else: +    print("NO")