N,P = map(int, input().split()) def gcd(a, b): if a < b: a, b = b, a if a%b == 0: return b return gcd(b, a%b) if P > 1: L = [0]*(N+1) n = 2 num = P while n <= P**0.5: if P%n == 0: num = n break n += 1 if num*2 <= N: ans = 0 for i in range(2, N+1): if i*2 <= N: ans += 1 continue n = 2 while n <= i**0.5: if i%n == 0: ans += 1 break n += 1 else: ans = 1 print(ans)