require 'prime' N=gets.to_i p Prime.instance.take(999).select{|e| e<=N}.reduce(:+)