import sys

sys.setrecursionlimit(10**6)

g=[]



def  jdream(l,i):

    if len(l)>=i+5:



        if l[i:i+5]=="dream":

            i=i+5

            if i==len(l):

                g.append("Y")

                return

     

            else:

                jer(l,i)

                jdream(l,i)

                return

        else:

            

            return

    else:

        

        return



def jerase(l,i):

    if len(l)>=i+5:



        if l[i:i+5]=="erase":

            i=i+5

            if i==len(l):

                g.append("Y")

                return

            else:

                jr(l,i)

                jerase(l,i)

                jdream(l,i)

                return

        else:

            

            return

    else:

        

        return



def jer(l,i):

    if len(l)>=i+2:



        if l[i:i+2]=="er":

            i=i+2

            if i==len(l):

                g.append("Y")

                return

            else:

                jase(l,i)

                jerase(l,i)

                jdream(l,i)

                return

        else:

            

            return

    else:

        

        return



def jase(l,i):

    if len(l)>=i+3:



        if l[i:i+3]=="ase":

            i=i+3

            if i==len(l):

                g.append("Y")

                return

            else:

                jdream(l,i)

                jerase(l,i)

                jr(l,i)

                return

        else:

            

            return

    else:

        

        return



def jr(l,i):

    if len(l)>=i+1:



        if l[i:i+1]=="r":

            i=i+1

            if i==len(l):

                g.append("Y")

                return

            else:

                jdream(l,i)

                jerase(l,i)

                return

        else:

            

            return



    else:

        

        return



s=eval(input())

n=0

jerase(s,n)

n=0

jdream(s,n)





if 'Y' in g:

    print("YES")

else:

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

n=len(s)

dp=list('false'*n)

dp[0]="true"

if s[0:5]=="dream" or s[0:5]=="erase":

    for i  in range(5):

        dp[i]="true"

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

    for i  in range(6):

        dp[i]="true"

if s[0:7]=="dreamer":

    for i in range(7):

        dp[i]="true"





for i in range(5,n):



    if dp[i-5]=="true" and (s[i-4:i+1]=="dream" or s[i-4:i+1]=="erase"):

        dp[i]="true"

    if dp[i-6]=="true" and s[i-5:i+1]=="eraser":

        dp[i]="true"

    if dp[i-7]=="true" and s[i-6:i+1]=="dreamer":

        dp[i]="true"



if dp[n-1]=="true":

    print("YES")

else:

    print("NO")
import sys

sys.setrecursionlimit(10**6)
g = []


def jdream(l, i):
    if len(l) >= i + 5:
        if l[i : i + 5] == "dream":
            i = i + 5
            if i == len(l):
                g.append("Y")
                return
            else:
                jer(l, i)
                jdream(l, i)
                return
        else:
            return
    else:
        return


def jerase(l, i):
    if len(l) >= i + 5:
        if l[i : i + 5] == "erase":
            i = i + 5
            if i == len(l):
                g.append("Y")
                return
            else:
                jr(l, i)
                jerase(l, i)
                jdream(l, i)
                return
        else:
            return
    else:
        return


def jer(l, i):
    if len(l) >= i + 2:
        if l[i : i + 2] == "er":
            i = i + 2
            if i == len(l):
                g.append("Y")
                return
            else:
                jase(l, i)
                jerase(l, i)
                jdream(l, i)
                return
        else:
            return
    else:
        return


def jase(l, i):
    if len(l) >= i + 3:
        if l[i : i + 3] == "ase":
            i = i + 3
            if i == len(l):
                g.append("Y")
                return
            else:
                jdream(l, i)
                jerase(l, i)
                jr(l, i)
                return
        else:
            return
    else:
        return


def jr(l, i):
    if len(l) >= i + 1:
        if l[i : i + 1] == "r":
            i = i + 1
            if i == len(l):
                g.append("Y")
                return
            else:
                jdream(l, i)
                jerase(l, i)
                return
        else:
            return
    else:
        return


s = eval(input())
n = 0
jerase(s, n)
n = 0
jdream(s, n)
if "Y" in g:
    print("YES")
else:
    print("NO")

s = eval(input())
n = len(s)
dp = list("false" * n)
dp[0] = "true"
if s[0:5] == "dream" or s[0:5] == "erase":
    for i in range(5):
        dp[i] = "true"
if s[0:6] == "eraser":
    for i in range(6):
        dp[i] = "true"
if s[0:7] == "dreamer":
    for i in range(7):
        dp[i] = "true"
for i in range(5, n):
    if dp[i - 5] == "true" and (
        s[i - 4 : i + 1] == "dream" or s[i - 4 : i + 1] == "erase"
    ):
        dp[i] = "true"
    if dp[i - 6] == "true" and s[i - 5 : i + 1] == "eraser":
        dp[i] = "true"
    if dp[i - 7] == "true" and s[i - 6 : i + 1] == "dreamer":
        dp[i] = "true"
if dp[n - 1] == "true":
    print("YES")
else:
    print("NO")

-import sys - -sys.setrecursionlimit(10**6) -g = [] - - -def jdream(l, i): -    if len(l) >= i + 5: -        if l[i : i + 5] == "dream": -            i = i + 5 -            if i == len(l): -                g.append("Y") -                return -            else: -                jer(l, i) -                jdream(l, i) -                return -        else: -            return -    else: -        return - - -def jerase(l, i): -    if len(l) >= i + 5: -        if l[i : i + 5] == "erase": -            i = i + 5 -            if i == len(l): -                g.append("Y") -                return -            else: -                jr(l, i) -                jerase(l, i) -                jdream(l, i) -                return -        else: -            return -    else: -        return - - -def jer(l, i): -    if len(l) >= i + 2: -        if l[i : i + 2] == "er": -            i = i + 2 -            if i == len(l): -                g.append("Y") -                return -            else: -                jase(l, i) -                jerase(l, i) -                jdream(l, i) -                return -        else: -            return -    else: -        return - - -def jase(l, i): -    if len(l) >= i + 3: -        if l[i : i + 3] == "ase": -            i = i + 3 -            if i == len(l): -                g.append("Y") -                return -            else: -                jdream(l, i) -                jerase(l, i) -                jr(l, i) -                return -        else: -            return -    else: -        return - - -def jr(l, i): -    if len(l) >= i + 1: -        if l[i : i + 1] == "r": -            i = i + 1 -            if i == len(l): -                g.append("Y") -                return -            else: -                jdream(l, i) -                jerase(l, i) -                return -        else: -            return -    else: -        return - - -n = 0 -jerase(s, n) -n = 0 -jdream(s, n) -if "Y" in g: +n = len(s) +dp = list("false" * n) +dp[0] = "true" +if s[0:5] == "dream" or s[0:5] == "erase": +    for i in range(5): +        dp[i] = "true" +if s[0:6] == "eraser": +    for i in range(6): +        dp[i] = "true" +if s[0:7] == "dreamer": +    for i in range(7): +        dp[i] = "true" +for i in range(5, n): +    if dp[i - 5] == "true" and ( +        s[i - 4 : i + 1] == "dream" or s[i - 4 : i + 1] == "erase" +    ): +        dp[i] = "true" +    if dp[i - 6] == "true" and s[i - 5 : i + 1] == "eraser": +        dp[i] = "true" +    if dp[i - 7] == "true" and s[i - 6 : i + 1] == "dreamer": +        dp[i] = "true" +if dp[n - 1] == "true":