S=eval(input())

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

stack=[]

stack.append(0)

while stack:

  index=stack.pop()

  if index==len(S):

    print("YES")

    break

  for data in datas:

    if index+len(data)>len(S):

      continue

    if S[index:index+len(data)]==data:

      stack.append(index+len(data))

else:

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

W=("dream","dreamer","erase","eraser")

s=[0]

while s:

  i=s.pop()

  if i==len(S):

    print("YES")

    break

  for w in W:

    if S[i:i+len(w)]==w:

      s.append(i+len(w))

else:

  print("NO")
S = eval(input())
datas = ["dream", "dreamer", "erase", "eraser"]
stack = []
stack.append(0)
while stack:
    index = stack.pop()
    if index == len(S):
        print("YES")
        break
    for data in datas:
        if index + len(data) > len(S):
            continue
        if S[index : index + len(data)] == data:
            stack.append(index + len(data))
else:
    print("NO")

S = eval(input())
W = ("dream", "dreamer", "erase", "eraser")
s = [0]
while s:
    i = s.pop()
    if i == len(S):
        print("YES")
        break
    for w in W:
        if S[i : i + len(w)] == w:
            s.append(i + len(w))
else:
    print("NO")

-datas = ["dream", "dreamer", "erase", "eraser"] -stack = [] -stack.append(0) -while stack: -    index = stack.pop() -    if index == len(S): +W = ("dream", "dreamer", "erase", "eraser") +s = [0] +while s: +    i = s.pop() +    if i == len(S): -    for data in datas: -        if index + len(data) > len(S): -            continue -        if S[index : index + len(data)] == data: -            stack.append(index + len(data)) +    for w in W: +        if S[i : i + len(w)] == w: +            s.append(i + len(w))