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

len_m = [len(m) for m in match]

S = eval(input())

n = len(S)

dp = [False] * (n + 1)

dp[0] = True

for i in range(1, n + 1):

    for lm, m in zip(len_m, match):

        if S[:i].endswith(m) and dp[i - lm]:

            dp[i] = True

            break

print(('YES' if dp[n] else 'NO'))
match = ['eraser', 'erase', 'dreamer', 'dream']

len_m = [len(m) for m in match]

S = eval(input())

n = len(S)

dp = [False] * (n + 1)

dp[0] = True

for i in range(1, n + 1):

    for w, word in zip(len_m, match):

        if S[i - w:i] == word and dp[i - w]:

            dp[i] = True

            break

print(('YES' if dp[n] else 'NO'))
match = ["eraser", "erase", "dreamer", "dream"]
len_m = [len(m) for m in match]
S = eval(input())
n = len(S)
dp = [False] * (n + 1)
dp[0] = True
for i in range(1, n + 1):
    for lm, m in zip(len_m, match):
        if S[:i].endswith(m) and dp[i - lm]:
            dp[i] = True
            break
print(("YES" if dp[n] else "NO"))

match = ["eraser", "erase", "dreamer", "dream"]
len_m = [len(m) for m in match]
S = eval(input())
n = len(S)
dp = [False] * (n + 1)
dp[0] = True
for i in range(1, n + 1):
    for w, word in zip(len_m, match):
        if S[i - w : i] == word and dp[i - w]:
            dp[i] = True
            break
print(("YES" if dp[n] else "NO"))

-    for lm, m in zip(len_m, match): -        if S[:i].endswith(m) and dp[i - lm]: +    for w, word in zip(len_m, match): +        if S[i - w : i] == word and dp[i - w]: