s = eval(input())

t = ''

result = 'YES'



scripts = ['dream', 'dreamer', 'erase', 'eraser']



while len(s) > len(t) and result == 'YES':

    restmp = False

    for script in scripts:

        tmp = t + script

        if tmp == s[:len(tmp)]:

            if tmp == s:

                t = tmp

                restmp = True

                break

            for script2 in scripts:

                tmp2 = tmp + script2

                if tmp2 == s[:len(tmp2)]:

                    t = tmp

                    restmp = True

                    break

            else:

                continue

            break



    if restmp is False:

        result = 'NO'



print(result)
s = eval(input())

t = ''

result = 'NO'



scripts = ['dream', 'dreamer', 'erase', 'eraser']



for i in range(len(scripts)):

    script = scripts[i]

    script = script[::-1]

    scripts[i] = script



s_rev = s[::-1]



while len(s) > 0:

    for script in scripts:

        if s_rev[:len(script)] == script:

            s_rev = s_rev[len(script):]

            break

    else:

        break



if s_rev == '':

    result = 'YES'

print(result)

s = eval(input())
t = ""
result = "YES"
scripts = ["dream", "dreamer", "erase", "eraser"]
while len(s) > len(t) and result == "YES":
    restmp = False
    for script in scripts:
        tmp = t + script
        if tmp == s[: len(tmp)]:
            if tmp == s:
                t = tmp
                restmp = True
                break
            for script2 in scripts:
                tmp2 = tmp + script2
                if tmp2 == s[: len(tmp2)]:
                    t = tmp
                    restmp = True
                    break
            else:
                continue
            break
    if restmp is False:
        result = "NO"
print(result)

s = eval(input())
t = ""
result = "NO"
scripts = ["dream", "dreamer", "erase", "eraser"]
for i in range(len(scripts)):
    script = scripts[i]
    script = script[::-1]
    scripts[i] = script
s_rev = s[::-1]
while len(s) > 0:
    for script in scripts:
        if s_rev[: len(script)] == script:
            s_rev = s_rev[len(script) :]
            break
    else:
        break
if s_rev == "":
    result = "YES"
print(result)

-result = "YES" +result = "NO" -while len(s) > len(t) and result == "YES": -    restmp = False +for i in range(len(scripts)): +    script = scripts[i] +    script = script[::-1] +    scripts[i] = script +s_rev = s[::-1] +while len(s) > 0: -        tmp = t + script -        if tmp == s[: len(tmp)]: -            if tmp == s: -                t = tmp -                restmp = True -                break -            for script2 in scripts: -                tmp2 = tmp + script2 -                if tmp2 == s[: len(tmp2)]: -                    t = tmp -                    restmp = True -                    break -            else: -                continue +        if s_rev[: len(script)] == script: +            s_rev = s_rev[len(script) :] -    if restmp is False: -        result = "NO" +    else: +        break +if s_rev == "": +    result = "YES"