while buf = gets
  primelist, searchlist, numlist, num = [], Array.new(buf.to_i - 1){|i| i + 2}, Array.new(buf.to_i){|i| i + 1}, 0
  unless buf.to_i == 1 || buf.to_i == 2
    loop do
      primelist << searchlist.first
      searchlist.reject! {|num| num % primelist.last == 0}
      break if primelist.last ** 2 > searchlist.last
    end
  end
  numlist.zip(numlist.reverse) {|i, r| num += 1 if (primelist + searchlist).include?(i) && (primelist + searchlist).include?(r)}
  puts num
end