let rec count_not_prime i j n h cnt =
  if j < n+1 then (
    if Hashtbl.mem h j then 
      count_not_prime i (j+i) n h cnt
    else (
      Hashtbl.add h j 1;
      count_not_prime i (j+i) n h (cnt+1)
    )
  )
  else if i < n+1 then
    count_not_prime (i+1) ((i+1)*2) n h cnt
  else
    cnt;;

let rec loop () =
  try 
    let n = read_int () in
    if n > 4 then (
      let h = Hashtbl.create 999999 in
      let cnt = count_not_prime 2 4 n h 0 in
      print_endline(string_of_int(n-cnt-1));
    )
    else if n > 1 then 
      print_endline("2")
    else
      print_endline("0");
    loop ();
  with End_of_file -> ();;

let () =
  loop ()