str_list = ["dream","erase","er","ase","r",]



class stringJudge():

    def __init__(self,string,string_list):

        self.string = string

        self.string_list = string_list

        

    def isNextMatch(self):

        for (i,str_val) in enumerate(str_list):

            if self.string.startswith(str_val):

                self.string = self.string.split(str_val,1)[1]

                if len(self.string) == 0:

                    return True

                if i ==0:

                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[2]):

                        return True

                elif i == 1:

                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]) or self.string.startswith(self.string_list[4]):

                        return True

                elif i == 2:

                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]) or self.string.startswith(self.string_list[3]):

                        return True

                elif i == 3:

                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1])  or self.string.startswith(self.string_list[4]):

                        return True

                elif i == 4:

                    if self.string.startswith(self.string_list[0]) or self.string.startswith(self.string_list[1]):

                        return True

        return False

                    

                    

           

    

instance = stringJudge(eval(input()),str_list)

check = True

while check and len(instance.string) > 0:

    check = instance.isNextMatch()



print(('YES' if check else 'NO'))
str_list = ["dream","dreamer","erase","eraser"]



class stringJudge():

    def __init__(self,string,string_list):

        self.string = string

        self.string_list = string_list

        

    def isNextMatch(self):

        for str_val in self.string_list:

            if self.string.endswith(str_val):

                self.string = self.string.rsplit(str_val,1)[0]

                return True

        return False

               

                    

                    

           

    

instance = stringJudge(eval(input()),str_list)

check = True

while check and len(instance.string) > 0:

    check = instance.isNextMatch()



print(('YES' if check else 'NO'))
str_list = [
    "dream",
    "erase",
    "er",
    "ase",
    "r",
]


class stringJudge:
    def __init__(self, string, string_list):
        self.string = string
        self.string_list = string_list

    def isNextMatch(self):
        for (i, str_val) in enumerate(str_list):
            if self.string.startswith(str_val):
                self.string = self.string.split(str_val, 1)[1]
                if len(self.string) == 0:
                    return True
                if i == 0:
                    if self.string.startswith(
                        self.string_list[0]
                    ) or self.string.startswith(self.string_list[2]):
                        return True
                elif i == 1:
                    if (
                        self.string.startswith(self.string_list[0])
                        or self.string.startswith(self.string_list[1])
                        or self.string.startswith(self.string_list[4])
                    ):
                        return True
                elif i == 2:
                    if (
                        self.string.startswith(self.string_list[0])
                        or self.string.startswith(self.string_list[1])
                        or self.string.startswith(self.string_list[3])
                    ):
                        return True
                elif i == 3:
                    if (
                        self.string.startswith(self.string_list[0])
                        or self.string.startswith(self.string_list[1])
                        or self.string.startswith(self.string_list[4])
                    ):
                        return True
                elif i == 4:
                    if self.string.startswith(
                        self.string_list[0]
                    ) or self.string.startswith(self.string_list[1]):
                        return True
        return False


instance = stringJudge(eval(input()), str_list)
check = True
while check and len(instance.string) > 0:
    check = instance.isNextMatch()
print(("YES" if check else "NO"))

str_list = ["dream", "dreamer", "erase", "eraser"]


class stringJudge:
    def __init__(self, string, string_list):
        self.string = string
        self.string_list = string_list

    def isNextMatch(self):
        for str_val in self.string_list:
            if self.string.endswith(str_val):
                self.string = self.string.rsplit(str_val, 1)[0]
                return True
        return False


instance = stringJudge(eval(input()), str_list)
check = True
while check and len(instance.string) > 0:
    check = instance.isNextMatch()
print(("YES" if check else "NO"))

-str_list = [ -    "dream", -    "erase", -    "er", -    "ase", -    "r", -] +str_list = ["dream", "dreamer", "erase", "eraser"] -        for (i, str_val) in enumerate(str_list): -            if self.string.startswith(str_val): -                self.string = self.string.split(str_val, 1)[1] -                if len(self.string) == 0: -                    return True -                if i == 0: -                    if self.string.startswith( -                        self.string_list[0] -                    ) or self.string.startswith(self.string_list[2]): -                        return True -                elif i == 1: -                    if ( -                        self.string.startswith(self.string_list[0]) -                        or self.string.startswith(self.string_list[1]) -                        or self.string.startswith(self.string_list[4]) -                    ): -                        return True -                elif i == 2: -                    if ( -                        self.string.startswith(self.string_list[0]) -                        or self.string.startswith(self.string_list[1]) -                        or self.string.startswith(self.string_list[3]) -                    ): -                        return True -                elif i == 3: -                    if ( -                        self.string.startswith(self.string_list[0]) -                        or self.string.startswith(self.string_list[1]) -                        or self.string.startswith(self.string_list[4]) -                    ): -                        return True -                elif i == 4: -                    if self.string.startswith( -                        self.string_list[0] -                    ) or self.string.startswith(self.string_list[1]): -                        return True +        for str_val in self.string_list: +            if self.string.endswith(str_val): +                self.string = self.string.rsplit(str_val, 1)[0] +                return True