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`.
s = input()
a = ['dream', 'dreamer', 'erase', 'eraser']
for _ in range(4):
  s.replace(a[_], "")
if s=="":
  print("YES")
else:
  print("NO")

s = input()
a = ['eraser', 'erase', 'dreamer', 'dream']
for i in range(4):
  s = s.replace(a[i], "")
print("YES" if s=="" else "NO")