S = input()[::-1]

words = {w[-1]:w[::-1] for w in ['dream', 'erase', 'er']}

i = 0

flag = True

#print(words)

while i < len(S):

  c = S[i]

  if c in words:

    if S[i:i+len(words[c])] == words[c]:

      i += len(words[c])

    else :

      flag = False

      break

    if c == 'r':

       if S[i:i+len(words['m'])] == words['m']:

         i += len(words['m'])

       elif S[i-1:i-1+len(words['e'])] == words['e']:

         i += len(words['e']) - 1

       else :

         flag = False

         break

  else :

    break

  if not flag:

    break

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



pos = len(s)

while pos > 0:

    # print(s[pos-6:pos])

    if s[pos-1] == 'e':

        if s[pos-5:pos] == 'erase':

            # print(s[pos-5:pos])

            pos -= 5

        else:

            break

    elif s[pos-1] == 'm':

        if s[pos-5:pos] == 'dream':

            # print(s[pos-5:pos])

            pos -= 5

        else:

            break

    elif s[pos-6:pos] == 'eraser':

        # print(s[pos-6:pos])

        pos -= 6

    elif s[pos-7:pos] == 'dreamer':

        # print(s[pos-7:pos])

        pos -= 7

    else:

        break

print(('YES' if pos <= 0 else 'NO'))



S = input()[::-1]
words = {w[-1]: w[::-1] for w in ["dream", "erase", "er"]}
i = 0
flag = True
# print(words)
while i < len(S):
    c = S[i]
    if c in words:
        if S[i : i + len(words[c])] == words[c]:
            i += len(words[c])
        else:
            flag = False
            break
        if c == "r":
            if S[i : i + len(words["m"])] == words["m"]:
                i += len(words["m"])
            elif S[i - 1 : i - 1 + len(words["e"])] == words["e"]:
                i += len(words["e"]) - 1
            else:
                flag = False
                break
    else:
        break
    if not flag:
        break
print(("YES" if flag else "NO"))

s = eval(input())
pos = len(s)
while pos > 0:
    # print(s[pos-6:pos])
    if s[pos - 1] == "e":
        if s[pos - 5 : pos] == "erase":
            # print(s[pos-5:pos])
            pos -= 5
        else:
            break
    elif s[pos - 1] == "m":
        if s[pos - 5 : pos] == "dream":
            # print(s[pos-5:pos])
            pos -= 5
        else:
            break
    elif s[pos - 6 : pos] == "eraser":
        # print(s[pos-6:pos])
        pos -= 6
    elif s[pos - 7 : pos] == "dreamer":
        # print(s[pos-7:pos])
        pos -= 7
    else:
        break
print(("YES" if pos <= 0 else "NO"))

-S = input()[::-1] -words = {w[-1]: w[::-1] for w in ["dream", "erase", "er"]} -i = 0 -flag = True -# print(words) -while i < len(S): -    c = S[i] -    if c in words: -        if S[i : i + len(words[c])] == words[c]: -            i += len(words[c]) +s = eval(input()) +pos = len(s) +while pos > 0: +    # print(s[pos-6:pos]) +    if s[pos - 1] == "e": +        if s[pos - 5 : pos] == "erase": +            # print(s[pos-5:pos]) +            pos -= 5 -            flag = False -        if c == "r": -            if S[i : i + len(words["m"])] == words["m"]: -                i += len(words["m"]) -            elif S[i - 1 : i - 1 + len(words["e"])] == words["e"]: -                i += len(words["e"]) - 1 -            else: -                flag = False -                break +    elif s[pos - 1] == "m": +        if s[pos - 5 : pos] == "dream": +            # print(s[pos-5:pos]) +            pos -= 5 +        else: +            break +    elif s[pos - 6 : pos] == "eraser": +        # print(s[pos-6:pos]) +        pos -= 6 +    elif s[pos - 7 : pos] == "dreamer": +        # print(s[pos-7:pos]) +        pos -= 7 -    if not flag: -        break -print(("YES" if flag else "NO")) +print(("YES" if pos <= 0 else "NO"))