S = list(eval(input()))

N = len(S)



for i in range(10):

  S.append('')



judge = 1

s1,s2,prev_s1 = '','',''

i = 0

while(1):

 s1 = S[i]+S[i+1]+S[i+2]+S[i+3]+S[i+4]

 s2 = S[i]+S[i+1]

 s2_ = list(s2)

 if(s1 == ''):

  break

 if((s1 == 'erase')or(s1 == 'dream')): 

  i += 5

 elif(s2 == 'er'):

  if(prev_s1 == 'dream'):

    i += 2

  else: 

    judge = 0

    break

 elif(s2_[0] == 'r'):

  if(prev_s1 == 'erase'):

    i += 1

  else: 

    judge = 0

    break

 else:

    judge = 0

    break

 prev_s1 = s1



if(judge == 1):

  print('YES')

else:

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

words_r = ['eraser', 'erase', 'dreamer', 'dream']

for word_r in words_r:

    s = s.replace(word_r, '')

    #コードの意味:

    #s.replace(p,q) :文字列sにpという文字があればそれを先頭から順にqに置換していく

    #sはwords_rに含まれる文字列を''に置換した文字列になる

    #->条件に合うならｓは最終的に''に,そうでないならそれ以外になる

if (len(s) > 0):

    print('NO')

else:

    print('YES')
S = list(eval(input()))
N = len(S)
for i in range(10):
    S.append("")
judge = 1
s1, s2, prev_s1 = "", "", ""
i = 0
while 1:
    s1 = S[i] + S[i + 1] + S[i + 2] + S[i + 3] + S[i + 4]
    s2 = S[i] + S[i + 1]
    s2_ = list(s2)
    if s1 == "":
        break
    if (s1 == "erase") or (s1 == "dream"):
        i += 5
    elif s2 == "er":
        if prev_s1 == "dream":
            i += 2
        else:
            judge = 0
            break
    elif s2_[0] == "r":
        if prev_s1 == "erase":
            i += 1
        else:
            judge = 0
            break
    else:
        judge = 0
        break
    prev_s1 = s1
if judge == 1:
    print("YES")
else:
    print("NO")

s = eval(input())
words_r = ["eraser", "erase", "dreamer", "dream"]
for word_r in words_r:
    s = s.replace(word_r, "")
    # コードの意味:
    # s.replace(p,q) :文字列sにpという文字があればそれを先頭から順にqに置換していく
    # sはwords_rに含まれる文字列を''に置換した文字列になる
    # ->条件に合うならｓは最終的に''に,そうでないならそれ以外になる
if len(s) > 0:
    print("NO")
else:
    print("YES")

-S = list(eval(input())) -N = len(S) -for i in range(10): -    S.append("") -judge = 1 -s1, s2, prev_s1 = "", "", "" -i = 0 -while 1: -    s1 = S[i] + S[i + 1] + S[i + 2] + S[i + 3] + S[i + 4] -    s2 = S[i] + S[i + 1] -    s2_ = list(s2) -    if s1 == "": -        break -    if (s1 == "erase") or (s1 == "dream"): -        i += 5 -    elif s2 == "er": -        if prev_s1 == "dream": -            i += 2 -        else: -            judge = 0 -            break -    elif s2_[0] == "r": -        if prev_s1 == "erase": -            i += 1 -        else: -            judge = 0 -            break -    else: -        judge = 0 -        break -    prev_s1 = s1 -if judge == 1: +s = eval(input()) +words_r = ["eraser", "erase", "dreamer", "dream"] +for word_r in words_r: +    s = s.replace(word_r, "") +    # コードの意味: +    # s.replace(p,q) :文字列sにpという文字があればそれを先頭から順にqに置換していく +    # sはwords_rに含まれる文字列を''に置換した文字列になる +    # ->条件に合うならｓは最終的に''に,そうでないならそれ以外になる +if len(s) > 0: +    print("NO") +else: -else: -    print("NO")