    fun main(args: Array<String>) {
        val sc = if (args.size > 1) java.util.Scanner(java.io.File(args[1])) else java.util.Scanner(System.`in`)
        solve(sc)
    }

    fun solve(sc: java.util.Scanner) {
        val c = arrayOf("dream", "dreamer", "erase", "eraser")
        var S = sc.next()

        do {
            val found = c.filter { S.endsWith(it) }
            found.forEach { S = S.dropLast(it.length) }
        } while (found.count() > 0)
        println(if (S.isEmpty()) "YES"  else "NO")
    }
