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 = eval(input())

while len(S) > 0:

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

        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 = eval(input())
while len(S) > 0:
    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")
        quit()
print("YES")

-    if "".join(S[-5:]) == "dream" or "".join(S[-5:]) == "erase": +    if S[-5:] == "dream" or S[-5:] == "erase": -    elif "".join(S[-6:]) == "eraser": +    elif S[-6:] == "eraser": -    elif "".join(S[-7:]) == "dreamer": +    elif S[-7:] == "dreamer":