let mod_exp x n m =
  let rec aux acc x = function
      0 -> acc
    | n ->
      aux
        (match n land 1 with
         | 1 -> (acc * x) mod m
         | _ -> acc)
        ((x * x) mod m)
        (n asr 1)
  in
  aux 1 x n
 
let div_pow_2 n =
  let rec aux s d = match d mod 2 with
      0 -> aux (s+1) (d/2)
    | _ -> s,d
  in aux 0 n
 
let miller_rabin n a =
  let s,d = div_pow_2 (n-1) in
  let a_exp_d = mod_exp a d n in
  let double x = mod_exp x 2 n in
  let rec loop e = function
      0 -> false
    | i ->
      match e with
        r when r = n - 1 -> true
      | r -> loop (double e) (i-1)
  in
  a_exp_d = 1 || loop a_exp_d s

let miller_rabin_test n k =
  let rec loop = function
      0 -> true
    | i ->
      let a = Random.int (n-1) |> (+) 1 in
      match miller_rabin n a with
        true -> loop (i-1)
      | false -> false
  in loop k

let count_primes n =
  let count = ref 0 in
  for x = 2 to n do
    match miller_rabin_test x 20 with
      true -> count := !count + 1
    | false -> ()
  done;
  !count
  
let () =
  try
    while true do
      let n = read_int () in
      Printf.printf "%d\n" (count_primes n)
    done
  with
    End_of_file -> ()