program abc049c
    use,intrinsic :: iso_fortran_env
    implicit none
    character(100000):: s
    character(:),allocatable:: dream, dreamer, erase, eraser
    integer(int32):: i

    read*, s
    dream = 'dream'
    dreamer = 'dreamer'
    erase = 'erase'
    eraser = 'eraser'

    if (dfs(s)) then
        print'(a)', 'YES'
    else
        print'(a)', 'NO'
    end if
contains
    recursive function dfs(s) result(ret)
        character(*):: s
        logical:: ret
        ret = .false.
        if (trim(s) == '') then
            ret = .true.
            return
        end if

        if (s(1:5) == dream) ret = ret .or. dfs(s(6:))
        if (s(1:7) == dreamer) ret = ret .or. dfs(s(8:))
        if (s(1:5) == erase) ret = ret .or. dfs(s(6:))
        if (s(1:6) == eraser) ret = ret .or. dfs(s(7:))
    end function
end program abc049c