S = input()[::-1]

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

day_dream_word = list([s[::-1] for s in day_dream_word])

T = ""

Tindex = 0

res = False

partial_res = True

while not res and partial_res:

  partial_res = False

  for add_word in day_dream_word:

    nextTindex = Tindex + len(add_word)

    

    if S[Tindex:nextTindex] == add_word:

      if len(S) == nextTindex:

        res = True

        break

      else:

        partial_res = True

        break

  Tindex = nextTindex



if res:

  print('YES')

else:

  print('NO')
S = eval(input())

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

for replace_word in day_dream_word:

  S = S.replace(replace_word, "")



if S == "":

  print('YES')

else:

  print('NO')
S = input()[::-1]
day_dream_word = ["dreamer", "dream", "eraser", "erase"]
day_dream_word = list([s[::-1] for s in day_dream_word])
T = ""
Tindex = 0
res = False
partial_res = True
while not res and partial_res:
    partial_res = False
    for add_word in day_dream_word:
        nextTindex = Tindex + len(add_word)
        if S[Tindex:nextTindex] == add_word:
            if len(S) == nextTindex:
                res = True
                break
            else:
                partial_res = True
                break
    Tindex = nextTindex
if res:
    print("YES")
else:
    print("NO")

S = eval(input())
day_dream_word = ["eraser", "erase", "dreamer", "dream"]
for replace_word in day_dream_word:
    S = S.replace(replace_word, "")
if S == "":
    print("YES")
else:
    print("NO")

-S = input()[::-1] -day_dream_word = ["dreamer", "dream", "eraser", "erase"] -day_dream_word = list([s[::-1] for s in day_dream_word]) -T = "" -Tindex = 0 -res = False -partial_res = True -while not res and partial_res: -    partial_res = False -    for add_word in day_dream_word: -        nextTindex = Tindex + len(add_word) -        if S[Tindex:nextTindex] == add_word: -            if len(S) == nextTindex: -                res = True -                break -            else: -                partial_res = True -                break -    Tindex = nextTindex -if res: +S = eval(input()) +day_dream_word = ["eraser", "erase", "dreamer", "dream"] +for replace_word in day_dream_word: +    S = S.replace(replace_word, "") +if S == "":