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=input()[::-1]

W=("dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1])

ind=0

while ind<len(S):

  for w in W:

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

      ind+=len(w)

      break

  else:

    print("NO")

    break

else:

  print("YES")
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 = input()[::-1]
W = ("dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1])
ind = 0
while ind < len(S):
    for w in W:
        if S[ind : ind + len(w)] == w:
            ind += len(w)
            break
    else:
        print("NO")
        break
else:
    print("YES")

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