S = eval(input())

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

chara = ''.join(reversed(list(S)))

flag = True

while flag:

    cnt = 0

    for i in dd:

        r = ''.join(reversed(list(i)))

        if r in chara[:len(r)]:

            chara = chara[len(r):]

            break

        cnt += 1

    if cnt == 4:

        flag = False



if chara == '':

    print('YES')

else:

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

while len(S) > 0:

    if 'dream' in S[-5:]:

        S = S[:-5]

        continue

    if 'dreamer' in S[-7:]:

        S = S[:-7]

        continue

    if 'erase' in S[-5:]:

        S = S[:-5]

        continue

    if 'eraser' in S[-6:]:

        S = S[:-6]

        continue

    break

if S == '':

    print('YES')

else:

    print('NO')
S = eval(input())
dd = ["dream", "dreamer", "erase", "eraser"]
chara = "".join(reversed(list(S)))
flag = True
while flag:
    cnt = 0
    for i in dd:
        r = "".join(reversed(list(i)))
        if r in chara[: len(r)]:
            chara = chara[len(r) :]
            break
        cnt += 1
    if cnt == 4:
        flag = False
if chara == "":
    print("YES")
else:
    print("NO")

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

-dd = ["dream", "dreamer", "erase", "eraser"] -chara = "".join(reversed(list(S))) -flag = True -while flag: -    cnt = 0 -    for i in dd: -        r = "".join(reversed(list(i))) -        if r in chara[: len(r)]: -            chara = chara[len(r) :] -            break -        cnt += 1 -    if cnt == 4: -        flag = False -if chara == "": +while len(S) > 0: +    if "dream" in S[-5:]: +        S = S[:-5] +        continue +    if "dreamer" in S[-7:]: +        S = S[:-7] +        continue +    if "erase" in S[-5:]: +        S = S[:-5] +        continue +    if "eraser" in S[-6:]: +        S = S[:-6] +        continue +    break +if S == "":