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: import sys
  import resource
  sys.setrecursionlimit(100000)
  
  def hantei(S):
    if S == 'dream' or S == 'dreamer' or S == 'erase' or S == 'eraser':
      return 1
    if S[:5] == 'dream' 
      if S[:7] == 'dreamer'
        return hantei(S[5:]) | hantei(S[7:])
      else:
        return hantei(S[5:])
    if S[:5] == 'erase' 
      if S[:6] == 'eraser'
        return hantei(S[5:]) | hantei(S[6:])
      else:
        return hantei(S[5:])
    else:
      return 0
  
  S = input()
  if(hantei(S)):
    print('YES')
  else:
    print('NO')
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"}]