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