s=eval(input())

n=len(s)

i=1

for j in range(n):

    if s[-i:-i-5:-1]=="maerd":

        i+=5

 

    if s[-i:-i-5:-1]=="esare":

        i+=5



    if s[-i:-i-6:-1]=="resare":

        i+=6



    if s[-i:-i-7:-1]=="remaerd":

        i+=7



    if i==n+1:

        print("YES")

        break



if i != n+1:

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

n=len(s)

i=1

for j in range(n//5):

    if s[-i:-i-5:-1]=="maerd":

        i+=5

 

    if s[-i:-i-5:-1]=="esare":

        i+=5



    if s[-i:-i-6:-1]=="resare":

        i+=6



    if s[-i:-i-7:-1]=="remaerd":

        i+=7



    if i==n+1:

        print("YES")

        break



if i != n+1:

    print("NO")
s = eval(input())
n = len(s)
i = 1
for j in range(n):
    if s[-i : -i - 5 : -1] == "maerd":
        i += 5
    if s[-i : -i - 5 : -1] == "esare":
        i += 5
    if s[-i : -i - 6 : -1] == "resare":
        i += 6
    if s[-i : -i - 7 : -1] == "remaerd":
        i += 7
    if i == n + 1:
        print("YES")
        break
if i != n + 1:
    print("NO")

s = eval(input())
n = len(s)
i = 1
for j in range(n // 5):
    if s[-i : -i - 5 : -1] == "maerd":
        i += 5
    if s[-i : -i - 5 : -1] == "esare":
        i += 5
    if s[-i : -i - 6 : -1] == "resare":
        i += 6
    if s[-i : -i - 7 : -1] == "remaerd":
        i += 7
    if i == n + 1:
        print("YES")
        break
if i != n + 1:
    print("NO")

-for j in range(n): +for j in range(n // 5):