"use strict";

/**
 * @param {string} x 
 */
const reverse = x => x.split("").reverse().join("");

/**
 * @param {string} s 
 */
const test = function(s, words) {
    if (s.length === 0) {
        return true;
    } else {
        const word = words.find(w => s.substr(0, w.length) === w);
        if (word !== undefined) {
            return test(s.substr(word.length), words)
        } else {
            return false;
        }
    }
}

/**
 * Resolves problem.
 * @param  {string} input
 * @returns {string}
 */
var main = function(input) {
    const words = ["dream", "dreamer", "erase", "eraser"]
        .map(reverse);
    const S = reverse(input);
    return test(S, words) ? "YES" : "NO";
};

const output = main(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(output); // console.log outputs with trailing new line!
