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: s = input()
  # curs = [index1, index2]
  curs = [0]
  while True:
      next_curs = []
      break_ = False
      for c in curs:
          # print(c)
          if s[c : c + 5] == "dream":
              next_curs.append(c + 5)
              if len(s) == c + 5:
                  break_ = True
          if s[c : c + 7] == "dreamer":
              next_curs.append(c + 7)
              if len(s) == c + 7:
                  break_ = True
          if s[c : c + 5] == "erase":
              next_curs.append(c + 5)
              if len(s) == c + 5:
                  break_ = True
          if s[c : c + 6] == "eraser":
              next_curs.append(c + 6)
              if len(s) == c + 6:
                  break_ = True
      if next_curs == []:
          print("No")
          break
      if break_:
          print("Yes")
          break
      curs = next_curs
  
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"}]