S = eval(input())

cursor = len(S)



while cursor:

    if S[cursor - 5: cursor] in ['dream', 'erase']:

        cursor -= 5

        continue

    elif S[cursor - 6: cursor] in ['eraser']:

        cursor -= 6

        continue

    elif S[cursor - 7: cursor] in ['dreamer']:

        cursor -= 7

    else:

        break



if cursor == 0:

    print('YES')

else:

    print('NO')



A = ['maerd', 'remaerd', 'esare', 'resare']

S = input()[::-1]

cur = 0

N = len(S)

ans = 'YES'

while cur < N:

    if S[cur: cur + 7] in A:

        cur += 7

    elif S[cur: cur + 6] in A:

        cur += 6

    elif S[cur: cur + 5] in A:

        cur += 5

    else:

        ans = 'NO'

        break



print(ans)

S = eval(input())
cursor = len(S)
while cursor:
    if S[cursor - 5 : cursor] in ["dream", "erase"]:
        cursor -= 5
        continue
    elif S[cursor - 6 : cursor] in ["eraser"]:
        cursor -= 6
        continue
    elif S[cursor - 7 : cursor] in ["dreamer"]:
        cursor -= 7
    else:
        break
if cursor == 0:
    print("YES")
else:
    print("NO")

A = ["maerd", "remaerd", "esare", "resare"]
S = input()[::-1]
cur = 0
N = len(S)
ans = "YES"
while cur < N:
    if S[cur : cur + 7] in A:
        cur += 7
    elif S[cur : cur + 6] in A:
        cur += 6
    elif S[cur : cur + 5] in A:
        cur += 5
    else:
        ans = "NO"
        break
print(ans)

-S = eval(input()) -cursor = len(S) -while cursor: -    if S[cursor - 5 : cursor] in ["dream", "erase"]: -        cursor -= 5 -        continue -    elif S[cursor - 6 : cursor] in ["eraser"]: -        cursor -= 6 -        continue -    elif S[cursor - 7 : cursor] in ["dreamer"]: -        cursor -= 7 +A = ["maerd", "remaerd", "esare", "resare"] +S = input()[::-1] +cur = 0 +N = len(S) +ans = "YES" +while cur < N: +    if S[cur : cur + 7] in A: +        cur += 7 +    elif S[cur : cur + 6] in A: +        cur += 6 +    elif S[cur : cur + 5] in A: +        cur += 5 +        ans = "NO" -if cursor == 0: -    print("YES") -else: -    print("NO") +print(ans)