let sl = Str.split (Str.regexp " ") @@ read_line ()
let il = List.map int_of_string sl

let calc l =
  let rec func five seven = function
    | [] -> if five = 2 && seven = 1 then print_endline "YES"
      else print_endline "NO"
    | x :: l' ->
      match x with
        5 -> func (five+1) seven l'
      | 7 -> func five (seven+1) l'
      | _ -> print_endline "NO"
  in func 0 0 l

let () = calc il