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 sys

def main():
    S = input()

    S = S.replace('dreamer', '').replace('dream', '').replace('erase', '').replace('eraser', '')
    print('Yes' if len(S)==0 else 'No')

if __name__ == '__main__':
    main()

import sys

def main():
    S = input()

    S = S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')
    print('YES' if len(S)==0 else 'NO')

if __name__ == '__main__':
    main()
