import sys

S = eval(input())

while S:

    if (S[-5:] == 'dream') or (S[-5:] == 'erase'):

        S = S[:-5]

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

        S = S[:-6]

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

        S = S[:-7]

    else:

        print('NO')

        sys.exit()

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



S = S.replace('eraser', '')

S = S.replace('erase', '')

S = S.replace('dreamer', '')

S = S.replace('dream', '')



if len(S) == 0:

    print('YES')

else:

    print('NO')
import sys

S = eval(input())
while S:
    if (S[-5:] == "dream") or (S[-5:] == "erase"):
        S = S[:-5]
    elif S[-6:] == "eraser":
        S = S[:-6]
    elif S[-7:] == "dreamer":
        S = S[:-7]
    else:
        print("NO")
        sys.exit()
print("YES")

S = eval(input())
S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")
if len(S) == 0:
    print("YES")
else:
    print("NO")

-import sys - -while S: -    if (S[-5:] == "dream") or (S[-5:] == "erase"): -        S = S[:-5] -    elif S[-6:] == "eraser": -        S = S[:-6] -    elif S[-7:] == "dreamer": -        S = S[:-7] -    else: -        print("NO") -        sys.exit() -print("YES") +S = S.replace("eraser", "") +S = S.replace("erase", "") +S = S.replace("dreamer", "") +S = S.replace("dream", "") +if len(S) == 0: +    print("YES") +else: +    print("NO")