require 'prime' N = gets.to_i ans = 0 if N == 2 puts 1 exit end Prime.each(N) do |r| q = r ** 2 - 2 next if N < q if q.prime? if r == q ans += 1 else ans += 2 end end end puts ans