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`.
s = str(input())

s.replace('dreamer','')
s.replace('eraser','')
s.replace('dream','')
s.replace('erase','')

if len(s) == 0:
  print('YES')
else:
  print('NO')

s = str(input())

while len(s) >= 0:
  if s[-7:] == 'dreamer':
    s = s[:-7]
  elif s[-6:] == 'eraser':
    s = s[:-6]
  elif s[-5:] == 'dream':
    s = s[:-5]
  elif s[-5:] == 'erase':
    s = s[:-5]
  else:
    break

if len(s) == 0:
  print('YES')
else:
  print('NO')