S = list(eval(input()))

while len(S) > 0:

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

        S = S[:-5]

    elif ''.join(S[-6:]) == 'eraser':

        S = S[:-6]

    elif ''.join(S[-7:]) == 'dreamer':

        S = S[:-7]

    else:

        print('NO')

        quit()

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

while len(S) > 0:

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

        S = S[:-5]

    elif ''.join(S[-6:]) == 'eraser':

        S = S[:-6]

    elif ''.join(S[-7:]) == 'dreamer':

        S = S[:-7]

    else:

        print('NO')

        quit()

print('YES')
S = list(eval(input()))
while len(S) > 0:
    if "".join(S[-5:]) == "dream" or "".join(S[-5:]) == "erase":
        S = S[:-5]
    elif "".join(S[-6:]) == "eraser":
        S = S[:-6]
    elif "".join(S[-7:]) == "dreamer":
        S = S[:-7]
    else:
        print("NO")
        quit()
print("YES")

S = eval(input())
while len(S) > 0:
    if "".join(S[-5:]) == "dream" or "".join(S[-5:]) == "erase":
        S = S[:-5]
    elif "".join(S[-6:]) == "eraser":
        S = S[:-6]
    elif "".join(S[-7:]) == "dreamer":
        S = S[:-7]
    else:
        print("NO")
        quit()
print("YES")

-S = list(eval(input())) +S = eval(input())