let rec find s = 
    match s with
    | [] -> true
    | 'r' :: 'e' :: 'm' :: 'a' :: 'e' :: 'r' :: 'd' :: tail -> find tail
    | 'm' :: 'a' :: 'e' :: 'r' :: 'd' :: tail -> find tail
    | 'r' :: 'e' :: 's' :: 'a' :: 'r' :: 'e' :: tail -> find tail
    | 'e' :: 's' :: 'a' :: 'r' :: 'e' :: tail -> find tail
    | _ -> false

let result flag = if flag then "YES" else "NO"

stdin.ReadLine().ToCharArray()
|> Array.toList
|> List.rev
|> find
|> result
|> printfn "%s"
