import math def sieve_of_eratosthenes(n): prime = [True for i in range(n+1)] prime[0] = False prime[1] = False sqrt_n = math.ceil(math.sqrt(n)) for i in range(2, sqrt_n): if prime[i]: for j in range(2*i, n+1, i): prime[j] = False return prime n,p = map(int,input().split()) prm = sieve_of_eratosthenes(n) pm = [] for i in range(n+1): if prm[i] == True: pm.append(i) mr = set() for i in range(len(pm)): if pm[i]*2 > n: #idx = i mr.add(pm[i]) #print(idx,pm[idx],len(pm)-idx) if p in mr: print(1) else: print(n-len(mr)-1)