from sys import setrecursionlimit setrecursionlimit(10**6) class UnionFind: def __init__(self, sz): self.par = [-1] * (sz+1) def root(self, pos): if self.par[pos] < 0: return pos self.par[pos] = self.root(self.par[pos]) return self.par[pos] def unite(self, u, v): u = self.root(u) v = self.root(v) if u == v: return self.par[u] += self.par[v] self.par[v] = u def same(self, u, v): if self.root(u) == self.root(v): return True return False def size(self, pos): return -self.par[self.root(pos)] def sieve_of_eratosthenes(N): P = UnionFind(N) flg = [0] * (N+1) for i in range(2,N+1): if flg[i] == 0: idx = i while idx <= N: P.unite(i, idx) flg[idx] = 1 idx += i return P N,P = map(int,input().split()) print(sieve_of_eratosthenes(N).size(P))