You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
import sys
inputs = input().rstrip()

lst = ["dream","dreamer","erase","eraser"]
for i in range(len(lst)):
    for j in range(len(lst)):
        if i == j:
            continue
        res = inputs.replace(lst[(i+j)%4],"").replace(lst[(i+j+1)%4],"").replace(lst[(i+j+2)%4],"").replace(lst[(i+j+3)%4],"")
        print(str((i+j)%4)+str((i+1+j)%4)+str((i+2+j)%4)+str((i+3+j)%4))
        if res == "":
            print("YES")
            exit(0)

print("NO")

import re;
str = input()
if re.match(r"^(dream|dreamer|erase|eraser)+$",str):
    print("YES")
    exit(0)
print("NO")