import java.util.*; public class Main { public static void main (String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); TreeSet primeSet = new TreeSet<>(); int total = 0; for (int i = 2; i <= n; i++) { if (isPrime(i, primeSet)) { total += i; primeSet.add(i); } } System.out.println(total); } static boolean isPrime(int x, TreeSet set) { for (int y : set) { if (y > Math.sqrt(x)) { break; } if (x % y == 0) { return false; } } return true; } }