import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int p= sc.nextInt(); sc.close(); if (p == 1) { System.out.println(1); return; } List sosuu = sosuuList(n); Set set = new HashSet(); int n2 = n / 2; for (Integer o : sosuu) { if (o > n2) { set.add(o); } } if (set.contains(p)) { System.out.println(1); } else { System.out.println(n - set.size() - 1); } } static List sosuuList(int n) { List sosuu = new ArrayList(); for (int i = 2; i <= n; i++) { int r = (int) Math.sqrt(i); boolean flg = false; for (Integer o : sosuu) { if (r < o) { break; } if (i % o == 0) { flg = true; break; } } if (!flg) { sosuu.add(i); } } return sosuu; } }