S = eval(input())

divide = ["dream", "dreamer", "erase", "eraser"]

S = S[::-1]

divide = [divide[i][::-1] for i in range(4)]

 

while len(S) > 0:

    for i in range(4):

        if S[:len(divide[i])] == divide[i]:

            flag = "YES"

            S = S[len(divide[i]):]

            break

        else:

            flag = "NO"

    if flag == "NO":

        break



print(flag)
S = eval(input())

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

for i in range(4):

    buff[i] = buff[i][::-1]

S = S[::-1]

while len(S) > 0:

    if S[:7] == buff[1]:

        S = S[7:]

    elif S[:6] == buff[3]:

        S = S[6:]

    elif S[:5] == buff[0] or S[:5] == buff[2]:

        S = S[5:]

    else:

        break

if S: print('NO')

else: print('YES')
S = eval(input())
divide = ["dream", "dreamer", "erase", "eraser"]
S = S[::-1]
divide = [divide[i][::-1] for i in range(4)]
while len(S) > 0:
    for i in range(4):
        if S[: len(divide[i])] == divide[i]:
            flag = "YES"
            S = S[len(divide[i]) :]
            break
        else:
            flag = "NO"
    if flag == "NO":
        break
print(flag)

S = eval(input())
buff = ["dream", "dreamer", "erase", "eraser"]
for i in range(4):
    buff[i] = buff[i][::-1]
S = S[::-1]
while len(S) > 0:
    if S[:7] == buff[1]:
        S = S[7:]
    elif S[:6] == buff[3]:
        S = S[6:]
    elif S[:5] == buff[0] or S[:5] == buff[2]:
        S = S[5:]
    else:
        break
if S:
    print("NO")
else:
    print("YES")

-divide = ["dream", "dreamer", "erase", "eraser"] +buff = ["dream", "dreamer", "erase", "eraser"] +for i in range(4): +    buff[i] = buff[i][::-1] -divide = [divide[i][::-1] for i in range(4)] -    for i in range(4): -        if S[: len(divide[i])] == divide[i]: -            flag = "YES" -            S = S[len(divide[i]) :] -            break -        else: -            flag = "NO" -    if flag == "NO": +    if S[:7] == buff[1]: +        S = S[7:] +    elif S[:6] == buff[3]: +        S = S[6:] +    elif S[:5] == buff[0] or S[:5] == buff[2]: +        S = S[5:] +    else: -print(flag) +if S: +    print("NO") +else: +    print("YES")