s_1 = eval(input())

s = s_1[::-1]

while len(s) >= 0:

  if s[0:5] == "maerd":

    s = s[5:len(s)]

    continue

  elif s[0:7] == "remaerd":

    s = s[7:len(s)]

    continue

  elif s[0:5] == "esare":

    s = s[5:len(s)]

    continue

  elif s[0:6] == "resare":

    s = s[6:len(s)]

    continue

  elif s == "":

    print("YES")

    break

  else:

    print("NO")

    break
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")

if len(s)>0:

  print("NO")

else:

  print("YES")
s_1 = eval(input())
s = s_1[::-1]
while len(s) >= 0:
    if s[0:5] == "maerd":
        s = s[5 : len(s)]
        continue
    elif s[0:7] == "remaerd":
        s = s[7 : len(s)]
        continue
    elif s[0:5] == "esare":
        s = s[5 : len(s)]
        continue
    elif s[0:6] == "resare":
        s = s[6 : len(s)]
        continue
    elif s == "":
        print("YES")
        break
    else:
        print("NO")
        break

s = (
    input()
    .replace("eraser", "")
    .replace("erase", "")
    .replace("dreamer", "")
    .replace("dream", "")
)
if len(s) > 0:
    print("NO")
else:
    print("YES")

-s_1 = eval(input()) -s = s_1[::-1] -while len(s) >= 0: -    if s[0:5] == "maerd": -        s = s[5 : len(s)] -        continue -    elif s[0:7] == "remaerd": -        s = s[7 : len(s)] -        continue -    elif s[0:5] == "esare": -        s = s[5 : len(s)] -        continue -    elif s[0:6] == "resare": -        s = s[6 : len(s)] -        continue -    elif s == "": -        print("YES") -        break -    else: -        print("NO") -        break +s = ( +    input() +    .replace("eraser", "") +    .replace("erase", "") +    .replace("dreamer", "") +    .replace("dream", "") +) +if len(s) > 0: +    print("NO") +else: +    print("YES")