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`.
import re

s = input()[::-1]

while len(s) > 0:
    for ptn in ['dream', 'dreamer', 'erase', 'eraser']:
        if re.match(ptn[::-1], s) is not None:
            s = s.replace(ptn[::-1], '')
            break
    else:
        break
print('Yes' if len(s) == 0 else 'No')
import re
print('YES' if re.match('(dream|dreamer|erase|eraser)+$', input()) else 'NO')