from sys import exit

s = eval(input())

ts = ['']

while True:

  nts= []

  for t in ts:

    for w in ['dreamer', 'eraser', 'dream', 'erase']:

      tw = t + w

      if s == tw:

        print('YES')

        exit()

      if s.startswith(tw):

        nts.append(tw)

  if len(nts) == 0:

    print('NO')

    exit()

  ts = nts

from sys import exit

s = input()[::-1]

while True:

  if s == '':

    print('YES')

    exit()

  for w in ['maerd', 'remaerd', 'esare', 'resare']:

    if s.startswith(w):

      s = s[len(w):]

      break

  else:

    print('NO')

    exit()

from sys import exit

s = eval(input())
ts = [""]
while True:
    nts = []
    for t in ts:
        for w in ["dreamer", "eraser", "dream", "erase"]:
            tw = t + w
            if s == tw:
                print("YES")
                exit()
            if s.startswith(tw):
                nts.append(tw)
    if len(nts) == 0:
        print("NO")
        exit()
    ts = nts

from sys import exit

s = input()[::-1]
while True:
    if s == "":
        print("YES")
        exit()
    for w in ["maerd", "remaerd", "esare", "resare"]:
        if s.startswith(w):
            s = s[len(w) :]
            break
    else:
        print("NO")
        exit()

-s = eval(input()) -ts = [""] +s = input()[::-1] -    nts = [] -    for t in ts: -        for w in ["dreamer", "eraser", "dream", "erase"]: -            tw = t + w -            if s == tw: -                print("YES") -                exit() -            if s.startswith(tw): -                nts.append(tw) -    if len(nts) == 0: +    if s == "": +        print("YES") +        exit() +    for w in ["maerd", "remaerd", "esare", "resare"]: +        if s.startswith(w): +            s = s[len(w) :] +            break +    else: -    ts = nts