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()
  while True:
  	S = s
  	if len(S) < 5:
  		print('NO')
  		break
  	if S == 'dream' or S == 'erase':
  		print('YES')
  		break
  	else:
  		if S[0] == 'd':
  			if S[7] == 'a':
  				T ='dream'
  				if S[:5] == T:
  					S = S[5:]
  					T = ""
  					if S == "":
  						print('YES')
  						break
  					s = S
  				else:
  					print('NO')
  					break
  			else:
  				T = 'dreamer'
  				if S[:7] == T:
  					S = S[7:]
  					T = ""
  					if S == "":
  						print('YES')
  						break
  					s = S
  				else:
  					print('NO')
  					break
  		if S[0] == 'e':
  			if len(S) >= 6 and S[5] == 'r':
  				T = 'eraser'
  				if S[:6] == T:
  					S = S[6:]
  					T = ""
  					if S == "":
  						print('YES')
  						break
  					s = S
  				else:
  					print('NO')
  					break
  			else:
  				T = 'erase'
  				if S[:5] == T:
  					S = S[5:]
  					T = ""
  					if S == "":
  						print('YES')
  						break
  					s = S
  				else:
  					print('NO')
  					break
  		else:
  			print('NO')
              break
  
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"}]