import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), m = sc.nextInt(), k = m - (n - 1) * 2, t; long sum = 0; if (k < 0) { System.out.println(0); return; } k = m / (n - 1); boolean[] b = new boolean[k + 1]; b[0] = true; b[1] = true; t = 1; while ((t + 1) * (t + 1) <= k) { t++; } for (int i = 2; i <= t; i++) { if (b[i]) { continue; } for (int j = i * i; j <= k; j += i) { b[j] = true; } } for (int i = 2; i <= k; i++) { if (!b[i]) { sum += (long) (m - (n - 1) * i + 1); } } System.out.println(sum); } }