import re



S = eval(input())

S = S[::-1] # 文字列反転



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



for i in range(len(pattern)):

    pattern[i] = pattern[i][::-1]



fin = False

while not fin:

    if S == '':

        print("YES")

        exit()

    fin = True

    for x in pattern:

        if re.match(x, S):

            S = S.replace(x, "", 1)

            fin = False

            break



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

s = ''

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

for i in range(1, len(S)+1):

    s = S[-i] + s

    if s in ar:

        s = ''

    if len(s) > 10:

        break



if len(s) == 0:

    print('YES')

else:

    print('NO')
import re

S = eval(input())
S = S[::-1]  # 文字列反転
pattern = ["dream", "dreamer", "erase", "eraser"]
for i in range(len(pattern)):
    pattern[i] = pattern[i][::-1]
fin = False
while not fin:
    if S == "":
        print("YES")
        exit()
    fin = True
    for x in pattern:
        if re.match(x, S):
            S = S.replace(x, "", 1)
            fin = False
            break
print("NO")

S = eval(input())
s = ""
ar = ["dream", "dreamer", "erase", "eraser"]
for i in range(1, len(S) + 1):
    s = S[-i] + s
    if s in ar:
        s = ""
    if len(s) > 10:
        break
if len(s) == 0:
    print("YES")
else:
    print("NO")

-import re - -S = S[::-1]  # 文字列反転 -pattern = ["dream", "dreamer", "erase", "eraser"] -for i in range(len(pattern)): -    pattern[i] = pattern[i][::-1] -fin = False -while not fin: -    if S == "": -        print("YES") -        exit() -    fin = True -    for x in pattern: -        if re.match(x, S): -            S = S.replace(x, "", 1) -            fin = False -            break -print("NO") +s = "" +ar = ["dream", "dreamer", "erase", "eraser"] +for i in range(1, len(S) + 1): +    s = S[-i] + s +    if s in ar: +        s = "" +    if len(s) > 10: +        break +if len(s) == 0: +    print("YES") +else: +    print("NO")