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 = list(input())
  
  false_flag = 0
  N = len(S)
  while N:
      if N >= 7:
          if (
              S[-1] == "r"
              and S[-2] == "e"
              and S[-3] == "m"
              and S[-4] == "a"
              and S[-5] == "e"
              and S[-6] == "r"
              and S[-7] == "d"
          ):
              for i in range(7):
                  S.pop()
          elif (
              S[-1] == "r"
              and S[-2] == "e"
              and S[-3] == "s"
              and S[-4] == "a"
              and S[-5] == "r"
              and S[-6] == "e"
          ):
              for i in range(6):
                  S.pop()
          elif (
              S[-1] == "m"
              and S[-2] == "a"
              and S[-3] == "e"
              and S[-4] == "r"
              and S[-5] == "d"
          ):
              for i in range(5):
                  S.pop()
          elif (
              S[-1] == "e"
              and S[-2] == "s"
              and S[-3] == "a"
              and S[-4] == "r"
              and S[-5] == "e"
          ):
              for i in range(5):
                  S.pop()
          else:
              false_flag = 1
              break
      elif N >= 6:
          if (
              S[-1] == "r"
              and S[-2] == "e"
              and S[-3] == "s"
              and S[-4] == "a"
              and S[-5] == "r"
              and S[-6] == "e"
          ):
              for i in range(6):
                  S.pop()
          elif (
              S[-1] == "m"
              and S[-2] == "a"
              and S[-3] == "e"
              and S[-4] == "r"
              and S[-5] == "d"
          ):
              for i in range(5):
                  S.pop()
          elif (
              S[-1] == "e"
              and S[-2] == "s"
              and S[-3] == "a"
              and S[-4] == "r"
              and S[-5] == "e"
          ):
              for i in range(5):
                  S.pop()
          else:
              false_flag = 1
              break
      elif N >= 5:
          if (
              S[-1] == "m"
              and S[-2] == "a"
              and S[-3] == "e"
              and S[-4] == "r"
              and S[-5] == "d"
          ):
              for i in range(5):
                  S.pop()
          elif (
              S[-1] == "e"
              and S[-2] == "s"
              and S[-3] == "a"
              and S[-4] == "r"
              and S[-5] == "e"
          ):
              for i in range(5):
                  S.pop()
          else:
              false_flag = 1
              break
      else:
          false_flag = 1
          break
      N = len(S)
  
  if false_flag == 1:
      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"}]