S=list(eval(input()))

l=0

while l!=len(S):

  l=len(S)

  if S[-1]=='m' and S[-2]=='a' and S[-3]=='e' and S[-4]=='r' and S[-5]=='d':

    del S[-5:]

  if len(S)==0:

    break

  if S[-1]=='e' and S[-2]=='s' and S[-3]=='a' and S[-4]=='r' and S[-5]=='e':

    del S[-5:]

  if len(S)==0:

    break

  if S[-1]=='r' and S[-2]=='e' and S[-3]=='s' and S[-4]=='a' and S[-5]=='r' and S[-6]=='e':

    del S[-6:]

  if len(S)==0:

    break

  if S[-1]=='r' and S[-2]=='e' and S[-3]=='m' and S[-4]=='a' and S[-5]=='e' and S[-6]=='r' and S[-7]=='d':

    del S[-7:]

  if len(S)==0:

    break



if len(S)==0:

  print('YES')

else:

  print('NO')
S = eval(input())

idx = len(S)

ans = 'YES'

while idx > 0:

    if S[idx-5:idx] == 'dream':

        idx -= 5

    elif S[idx-5:idx] == 'erase':

        idx -= 5

    elif S[idx-7:idx] == 'dreamer':

        idx -= 7

    elif S[idx-6:idx] == 'eraser':

        idx -= 6

    else:

        ans = 'NO'

        break

print(ans)
S = list(eval(input()))
l = 0
while l != len(S):
    l = len(S)
    if S[-1] == "m" and S[-2] == "a" and S[-3] == "e" and S[-4] == "r" and S[-5] == "d":
        del S[-5:]
    if len(S) == 0:
        break
    if S[-1] == "e" and S[-2] == "s" and S[-3] == "a" and S[-4] == "r" and S[-5] == "e":
        del S[-5:]
    if len(S) == 0:
        break
    if (
        S[-1] == "r"
        and S[-2] == "e"
        and S[-3] == "s"
        and S[-4] == "a"
        and S[-5] == "r"
        and S[-6] == "e"
    ):
        del S[-6:]
    if len(S) == 0:
        break
    if (
        S[-1] == "r"
        and S[-2] == "e"
        and S[-3] == "m"
        and S[-4] == "a"
        and S[-5] == "e"
        and S[-6] == "r"
        and S[-7] == "d"
    ):
        del S[-7:]
    if len(S) == 0:
        break
if len(S) == 0:
    print("YES")
else:
    print("NO")

S = eval(input())
idx = len(S)
ans = "YES"
while idx > 0:
    if S[idx - 5 : idx] == "dream":
        idx -= 5
    elif S[idx - 5 : idx] == "erase":
        idx -= 5
    elif S[idx - 7 : idx] == "dreamer":
        idx -= 7
    elif S[idx - 6 : idx] == "eraser":
        idx -= 6
    else:
        ans = "NO"
        break
print(ans)

-S = list(eval(input())) -l = 0 -while l != len(S): -    l = len(S) -    if S[-1] == "m" and S[-2] == "a" and S[-3] == "e" and S[-4] == "r" and S[-5] == "d": -        del S[-5:] -    if len(S) == 0: +S = eval(input()) +idx = len(S) +ans = "YES" +while idx > 0: +    if S[idx - 5 : idx] == "dream": +        idx -= 5 +    elif S[idx - 5 : idx] == "erase": +        idx -= 5 +    elif S[idx - 7 : idx] == "dreamer": +        idx -= 7 +    elif S[idx - 6 : idx] == "eraser": +        idx -= 6 +    else: +        ans = "NO" -    if S[-1] == "e" and S[-2] == "s" and S[-3] == "a" and S[-4] == "r" and S[-5] == "e": -        del S[-5:] -    if len(S) == 0: -        break -    if ( -        S[-1] == "r" -        and S[-2] == "e" -        and S[-3] == "s" -        and S[-4] == "a" -        and S[-5] == "r" -        and S[-6] == "e" -    ): -        del S[-6:] -    if len(S) == 0: -        break -    if ( -        S[-1] == "r" -        and S[-2] == "e" -        and S[-3] == "m" -        and S[-4] == "a" -        and S[-5] == "e" -        and S[-6] == "r" -        and S[-7] == "d" -    ): -        del S[-7:] -    if len(S) == 0: -        break -if len(S) == 0: -    print("YES") -else: -    print("NO") +print(ans)