#!/usr/bin/env pypy3 # 制約変更後の想定解 # 以前の#101936はリジャッジでAssertionErrorとなるはず import array import itertools MIN_N = 3 MAX_N = 10 ** 6 MIN_L = 1 MAX_L = 5 * 10 ** 6 # Eratosthenesの篩により、素数を列挙する # is_prime[i] (0 <= i < end): iは素数か? def sieve_of_eratosthenes(end): assert end > 1 is_prime = array.array("B", (True for _ in range(end))) is_prime[0] = False is_prime[1] = False for i in range(2, end): if is_prime[i]: for j in range(2 * i, end, i): is_prime[j] = False return is_prime # 素数計数関数π(x)の0 <= x <= lastに対する値をまとめた表を返す # 上のsieve_of_eratosthenesとは区間のとり方が異なる def pcf_table(last, typecode="L"): assert last >= 1 is_prime = sieve_of_eratosthenes(last + 1) # 式 pcf[i] = pcf[i - 1] + f(i)により表を作る # ただし、f(i)はiが素数なら1、さもなければ0とする pcf = array.array(typecode, itertools.accumulate(is_prime)) return pcf # 等素数間隔列を数える def count_seqs(n, l): # dの候補は1 <= d <= d_max(x0) def d_max(x0): return (l - x0) // (n - 1) # x0の候補は0 <= x0 <= x0_max x0_max = l - n + 1 # 可能なx0が存在しなければ、答えは0 if x0_max < 0: return 0 pcf = pcf_table(max(1, d_max(0))) return sum(pcf[d_max(x0)] for x0 in range(0, x0_max + 1)) def main(): n, l = map(int, input().split()) assert MIN_N <= n <= MAX_N # assert MIN_L <= l <= MAX_L print(count_seqs(n, l)) if __name__ == '__main__': main()