fun main(args: Array<String>) {
    var s = StringBuilder(readLine()!!)
    val words = listOf("dream", "erase", "eraser", "dreamer")
    whileloop@ while(s.isNotEmpty()) {
        for(word in words){
            if(s.endsWith(word)){
                s = s.delete(s.length - word.length, s.length)
                continue@whileloop
            }
        }
        println("NO")
        return
    }
    println("YES")
}