N,P = map(int,input().split()) l = [0]*(N+1) for i in range(2,N+1): for j in range(i,N+1,i): l[j] += 1 count = N-1 for n in range(N//2+1,N+1): if l[n] == 1: count -= 1 if l[P] == 1: print(1) else: print(count)