er = ["dreamer", "eraser"]

noter = ["dream", "erase"]

words = er + noter

s = eval(input())

while len(s) > 0:

  flag = True

  for word in words:

    if s.endswith(word):

      s = s[:-len(word)]

      flag = False

  if flag:

    print("NO")

    exit()

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

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

while len(S) > 0:

    flag = True

    for word in words:

        if S.endswith(word):

            flag = False

            S = S[:-len(word)]

    if flag:

        print("NO")

        exit(0)

print("YES")
er = ["dreamer", "eraser"]
noter = ["dream", "erase"]
words = er + noter
s = eval(input())
while len(s) > 0:
    flag = True
    for word in words:
        if s.endswith(word):
            s = s[: -len(word)]
            flag = False
    if flag:
        print("NO")
        exit()
print("YES")

S = eval(input())
words = ["dream", "dreamer", "erase", "eraser"]
while len(S) > 0:
    flag = True
    for word in words:
        if S.endswith(word):
            flag = False
            S = S[: -len(word)]
    if flag:
        print("NO")
        exit(0)
print("YES")

-er = ["dreamer", "eraser"] -noter = ["dream", "erase"] -words = er + noter -s = eval(input()) -while len(s) > 0: +S = eval(input()) +words = ["dream", "dreamer", "erase", "eraser"] +while len(S) > 0: -        if s.endswith(word): -            s = s[: -len(word)] +        if S.endswith(word): +            S = S[: -len(word)] -        exit() +        exit(0)