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: def hantei(s, h):
      try:
          slen = len(s)
          hlen = len(h)
          res = s.index(h, slen - hlen, slen + 1)
          return res
      except ValueError as e:
          return -1
  
  
  def resolve():
      s = input()
      a = "dream"
      b = "dreamer"
      c = "erase"
      d = "eraser"
      while True:
          # 後ろから文字列検索
          # 合ったらその文字を削除
          D = hantei(s, d)
          if D > -1:
              s = s[: -len(d)]
              continue
          B = hantei(s, b)
          if B > -1:
              s = s[: -len(b)]
              continue
          C = hantei(s, c)
          if C > -1:
              s = s[: -len(c)]
              continue
          A = hantei(s, a)
          if A > -1:
              s = s[: -len(a)]
              continue
          if len(s) == 0:
              print("YES")
          else:
              print("NO")
          break
  
  
  resolve()
  
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"}]