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()
W=["dream","dreamer","erase","eraser"]

ans="Yes"
while len(S)>0:
  if S.endswith(W[0]):
    S=S[:-len(W[0])]
  elif S.endswith(W[1]):
    S=S[:-len(W[1])]
  elif S.endswith(W[2]):
    S=S[:-len(W[2])]
  elif S.endswith(W[3]):
    S=S[:-len(W[3])]
  else:
    ans="No"
    break
    
print(ans)
S=input()
W=["dream","dreamer","erase","eraser"]

ans="YES"
while len(S)>0:
  if S.endswith(W[0]):
    S=S[:-len(W[0])]
  elif S.endswith(W[1]):
    S=S[:-len(W[1])]
  elif S.endswith(W[2]):
    S=S[:-len(W[2])]
  elif S.endswith(W[3]):
    S=S[:-len(W[3])]
  else:
    ans="NO"
    break
    
print(ans)