require 'prime' n = gets.to_i pli = Prime.take_while{|e| e <= n}.select{|q| z = q+2 h = Math.sqrt(z).to_i q != 2 && h**2 == z && h.prime? } p pli.size*2+1