s = eval(input())



stack = []

for c in reversed(s):

  stack.append(c)

  if len(stack) > 7:

    print('NO')

    break  

  if ''.join(reversed(stack)) in ('erase', 'dream', 'eraser', 'dreamer'):

    stack = []

else:

  print(('NO' if stack else 'YES'))
s = eval(input())

 

stack = []

for c in reversed(s):

  stack.append(c)

  if len(stack) > 7:

    print('NO')

    break  

  if len(stack) >= 5 and ''.join(reversed(stack)) in ('erase', 'dream', 'eraser', 'dreamer'):

    stack = []

else:

  print(('NO' if stack else 'YES'))
s = eval(input())
stack = []
for c in reversed(s):
    stack.append(c)
    if len(stack) > 7:
        print("NO")
        break
    if "".join(reversed(stack)) in ("erase", "dream", "eraser", "dreamer"):
        stack = []
else:
    print(("NO" if stack else "YES"))

s = eval(input())
stack = []
for c in reversed(s):
    stack.append(c)
    if len(stack) > 7:
        print("NO")
        break
    if len(stack) >= 5 and "".join(reversed(stack)) in (
        "erase",
        "dream",
        "eraser",
        "dreamer",
    ):
        stack = []
else:
    print(("NO" if stack else "YES"))

-    if "".join(reversed(stack)) in ("erase", "dream", "eraser", "dreamer"): +    if len(stack) >= 5 and "".join(reversed(stack)) in ( +        "erase", +        "dream", +        "eraser", +        "dreamer", +    ):