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())

T = S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')

if T == '':

    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())
T = (
    S.replace("eraser", "")
    .replace("erase", "")
    .replace("dreamer", "")
    .replace("dream", "")
)
if T == "":
    print("YES")
else:
    print("NO")

-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 == "": +T = ( +    S.replace("eraser", "") +    .replace("erase", "") +    .replace("dreamer", "") +    .replace("dream", "") +) +if T == "":