let pow_base x y mult =
  let rec f m n odd b = match n with
      0 -> 1
    | 1 -> mult m odd
    | _ -> let t = if n mod 2 = 1 then mult odd b else odd
           in f (mult m m) (n/2) t (mult b b)
  in f x y 1 x;;

let mpow x y z =
  let mult x1 y1 = ((x1 mod z)*(y1 mod z)) mod z in
  pow_base x y mult;;

let pow x y = pow_base x y ( * );;

let is_composite d n s =
  let l = [2;3;5;7] in
  let rec loop a = match a with
      [] -> false
    | h::t -> if (mpow h d n) = 1 then loop t
              else
                if not (let rec loop2 = function
                    i when i = s -> false
                  | i -> if mpow h ((pow 2 i) * d) n = n-1 then true
                         else loop2 (i+1) in loop2 0) then true
                else
                  loop t
  in loop l;;

let is_prime n = match n with
    2|3|5|7 -> true
    | n ->
       if n=1 || n mod 2 = 0 || n mod 3 = 0 || n mod 5 = 0 || n mod 7 = 0 then
         false
       else begin
           let rec loop d s = match (d, s) with
               (d, s) when d mod 2 = 1 -> (d,s)
             | (d, s) -> loop (d asr 1) (s+1) in
           let (d,s) = loop (n-1) 0 in
           not (is_composite d n s)
         end;;

let () =
  let n = read_int () in
  let rec read ct = function
      0 -> ct
    | i ->
       let m = read_int () in
       read (if is_prime m then ct+1 else ct) (i-1)
  in
  Printf.printf "%d\n" (read 0 n)