#!/usr/bin/env pypy3 # 制約再変更後の想定解 # Eratosthenesの篩を用いたPyPy3解がTLEになったため、 # Atkinの篩に切り替えた import array import itertools import math MIN_N = 3 MAX_N = 10 ** 6 MIN_L = 1 MAX_L = 2 * 10 ** 7 # Atkinの篩により、end未満の素数を列挙する # この実装では計算量O(end) # http://www.prefield.com/algorithm/math/sieve_of_atkin.html def sieve_of_atkin(end, typecode="L"): sl = math.floor(math.sqrt(end)) is_prime = array.array("B", (False for _ in range(end + 1))) for x, y in itertools.product(range(1, sl + 1), repeat=2): n = 4 * x * x + y * y if n <= end and (n % 12 == 1 or n % 12 == 5): is_prime[n] ^= True n = 3 * x * x + y * y if n <= end and n % 12 == 7: is_prime[n] ^= True n = 3 * x * x - y * y if x > y and n <= end and n % 12 == 11: is_prime[n] ^= True for n in range(5, sl + 1): if is_prime[n]: for k in range(n * n, end, n * n): is_prime[k] = False if end > 2: is_prime[2] = True if end > 3: is_prime[3] = True primes = array.array(typecode) primes.extend(p for p in range(end) if is_prime[p]) return primes def count_sequences(n, l): def x_max(d): return l - (n - 1) * d d_max = l // (n - 1) if d_max < 2: return 0 ds = sieve_of_atkin(d_max + 1) ans = sum(x_max(d) + 1 for d in ds) return ans def main(): n, l = map(int, input().split()) assert MIN_N <= n <= MAX_N assert MIN_L <= l <= MAX_L print(count_sequences(n, l)) if __name__ == '__main__': main()