require 'prime'
 
$primes_u10000 = Prime.each(10000).to_a
 
def prime?(n)
    return n == $primes_u10000.bsearch{|x| n <= x} if n <= 10000
 
    # trial division
    limit = Math.sqrt(n).floor
    $primes_u10000.each do |d|
        break if limit < d
        return false if n % d == 0
    end
 
    return true
end
 
p gets.to_i.times.count { prime? gets.to_i }