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()
l = len(S)
while l > 0:
  if S[l-5:l] == 'erase' or S[l-5:l] == 'dream':
    l -= 5
  elif S[l-6:l] == 'eraser':
    l -= 6
  elif S[l-7:l] == 'dreamer':
    l -= 7
  else:
    l = -10
  print(l)
    
if l == 0:
  print("YES")
else:
  print("NO")
S = input()
l = len(S)
while l > 0:
  if S[l-5:l] == 'erase' or S[l-5:l] == 'dream':
    l -= 5
  elif S[l-6:l] == 'eraser':
    l -= 6
  elif S[l-7:l] == 'dreamer':
    l -= 7
  else:
    l = -10
    
if l == 0:
  print("YES")
else:
  print("NO")