let () = Scanf.scanf "%d" @@ fun n ->
  Printf.printf "%d\n" @@
  List.length @@
  List.filter (( >= ) n) @@
  List.map (List.fold_left (fun acc -> ( + ) @@ 10 * acc) 0) @@
  List.filter (fun acc ->
    List.mem 7 acc && List.mem 5 acc && List.mem 3 acc) @@
  fst @@ Array.fold_left (fun (acc, curr) ds ->
    curr @ acc, List.concat @@ List.map (fun d ->
      List.map (fun curr -> d :: curr) curr) ds) ([[]], [[]]) @@
  Array.make 10 [7; 5; 3]

