s=eval(input())

while len(s)>7:

    if s[-5:]=='erase' or s[-5:]=='dream':

        s=s[:-5]

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

        s=s[:-6]

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

        s=s[:-7]

    else:

        break

if s=='' or s=='dreamer' or s=='eraser' or s=='erase' or s=='dream':

    print('YES')

else:

    print('NO')
s=eval(input())

while len(s)>7:

    if s[-5:]=='dream' or s[-5:]=='erase':

        s=s[:-5]

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

        s=s[:-6]

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

        s=s[:-7]

    else:

        print('NO')

        exit()

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

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

-    if s[-5:] == "erase" or s[-5:] == "dream": +    if s[-5:] == "dream" or s[-5:] == "erase": -        break -if s == "" or s == "dreamer" or s == "eraser" or s == "erase" or s == "dream": -    print("YES") -else: -    print("NO") +        print("NO") +        exit() +print( +    ( +        "YES" +        if s == "erase" or s == "dreamer" or s == "dream" or s == "eraser" or s == "" +        else "NO" +    ) +)