fun main(args: Array<String>) {
    val S = readLine()!!
    var T = S

    var peek: String?
    val pat = listOf("dream", "dreamer", "erase", "eraser")
    while (pat.firstOrNull { T.endsWith(it) }.also { peek = it } != null) {
        T = T.substringBeforeLast(peek!!)
    }
    print(if (T == "") "YES" else "NO")
}
