s = eval(input())

t = ""

while len(t) < len(s):

    target_len = len(s) - len(t)



    if s[len(t)] == 'd':

        if target_len == 5:

            t += "dream"

        elif target_len == 7:

            t += "dreamer"

        elif target_len > 7:

            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 7 + 1] != "era":

                t += "dreamer"

            else:

                t += "dream"

        else:

            break

    else:

        if target_len == 5:

            t += "erase"

        elif target_len == 6:

            t += "eraser"

        elif target_len > 6:

            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 6 + 2] != "era":

                t += "eraser"

            else:

                t += "erase"

        else:

            break



    if s[0:len(t)] != t:

        break



print(("YES" if s == t else "NO"))

s = eval(input())

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

rev = []

t = ""

s_rev = s[::-1]

for d in div:

    rev.append(d[::-1])



result = True

i = 0

while i < len(s):

    can_divide = False

    for d in rev:

        if len(s_rev) - i >= len(d) and s_rev[i:i + len(d)] == d:

            can_divide = True

            i += len(d)

            break

    if not can_divide:

        result = False

        break



print(("YES" if result else "NO"))

s = eval(input())
t = ""
while len(t) < len(s):
    target_len = len(s) - len(t)
    if s[len(t)] == "d":
        if target_len == 5:
            t += "dream"
        elif target_len == 7:
            t += "dreamer"
        elif target_len > 7:
            if s[len(t) + 5] != "d" and s[len(t) + 5 : len(t) + 7 + 1] != "era":
                t += "dreamer"
            else:
                t += "dream"
        else:
            break
    else:
        if target_len == 5:
            t += "erase"
        elif target_len == 6:
            t += "eraser"
        elif target_len > 6:
            if s[len(t) + 5] != "d" and s[len(t) + 5 : len(t) + 6 + 2] != "era":
                t += "eraser"
            else:
                t += "erase"
        else:
            break
    if s[0 : len(t)] != t:
        break
print(("YES" if s == t else "NO"))

s = eval(input())
div = ["dream", "dreamer", "erase", "eraser"]
rev = []
t = ""
s_rev = s[::-1]
for d in div:
    rev.append(d[::-1])
result = True
i = 0
while i < len(s):
    can_divide = False
    for d in rev:
        if len(s_rev) - i >= len(d) and s_rev[i : i + len(d)] == d:
            can_divide = True
            i += len(d)
            break
    if not can_divide:
        result = False
        break
print(("YES" if result else "NO"))

+div = ["dream", "dreamer", "erase", "eraser"] +rev = [] -while len(t) < len(s): -    target_len = len(s) - len(t) -    if s[len(t)] == "d": -        if target_len == 5: -            t += "dream" -        elif target_len == 7: -            t += "dreamer" -        elif target_len > 7: -            if s[len(t) + 5] != "d" and s[len(t) + 5 : len(t) + 7 + 1] != "era": -                t += "dreamer" -            else: -                t += "dream" -        else: +s_rev = s[::-1] +for d in div: +    rev.append(d[::-1]) +result = True +i = 0 +while i < len(s): +    can_divide = False +    for d in rev: +        if len(s_rev) - i >= len(d) and s_rev[i : i + len(d)] == d: +            can_divide = True +            i += len(d) -    else: -        if target_len == 5: -            t += "erase" -        elif target_len == 6: -            t += "eraser" -        elif target_len > 6: -            if s[len(t) + 5] != "d" and s[len(t) + 5 : len(t) + 6 + 2] != "era": -                t += "eraser" -            else: -                t += "erase" -        else: -            break -    if s[0 : len(t)] != t: +    if not can_divide: +        result = False -print(("YES" if s == t else "NO")) +print(("YES" if result else "NO"))