output_description: If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      S
attempt: l = list(input())
  a = [list("dream"), list("erase")]
  b = [list("eraser")]
  c = [list("dreamer")]
  n = len(l)
  r = 0
  while n <= 4:
      f = 0
      if n >= 7:
          if l[len(l) - 5 :] in a:
              l[len(l) - 5 :] = []
              n -= 5
              f += 1
          if l[len(l) - 6 :] in b:
              l[len(l) - 6 :] = []
              n -= 6
              f += 1
          if l[len(l) - 7 :] in c:
              l[len(l) - 7 :] = []
              n -= 7
              f += 1
      elif n >= 6:
          if l[len(l) - 5 :] in a:
              l[len(l) - 5 :] = []
              n -= 5
              f += 1
          if l[len(l) - 6 :] in b:
              l[len(l) - 6 :] = []
              n -= 6
              f += 1
      elif n >= 5:
          if l[len(l) - 5 :] in a:
              l[len(l) - 5 :] = []
              n -= 5
              f += 1
      if f == 0:
          r = 1
          break
  if r == 1 or n > 0:
      print("NO")
  else:
      print("YES")
  
problem_description: Statement
  
  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`.
samples: [{"input": "erasedream", "output": "YES\n    \n\nAppend `erase` and `dream` at the end of T in this order, to obtain S = T.\n\n* * *"}, {"input": "dreameraser", "output": "YES\n    \n\nAppend `dream` and `eraser` at the end of T in this order, to obtain S = T.\n\n* * *"}, {"input": "dreamerer", "output": "NO"}]