from collections import deque import math N,P=map(int,input().split()) def searchPrimeNum(N): max = int(math.sqrt(N)) searchList = [i for i in range(2,N+1)] primeNum = [] while searchList[0] <= max: primeNum.append(searchList[0]) tmp = searchList[0] searchList = [i for i in searchList if i % tmp != 0] primeNum.extend(searchList) return primeNum if P==1: print(1) else: E=[[] for _ in range(N)] table=searchPrimeNum(N) for v in table: i=2 while v*i<=N: E[v-1].append(v*i-1) E[v*i-1].append(v-1) i+=1 P-=1 seen=[0]*N seen[P]=1 stack=deque([P]) cnt=1 while stack: u=stack.pop() for v in E[u]: if seen[v]!=1: seen[v]=1 cnt+=1 stack.append(v) print(cnt)