#include using namespace std; struct UnionFind{ vector par; UnionFind(int N) : par(N){ for(int i = 0; i < N; i++){ par[i] = -1; } } int root(int x){ if(par[x] < 0) return x; else return par[x] = root(par[x]); } void unite(int x, int y){ int rx = root(x); int ry = root(y); if(rx == ry) return; else{ if(par[rx] > par[ry]) swap(rx, ry); par[rx] += par[ry]; par[ry] = rx; } } bool same(int x, int y){ return root(x) == root(y); } void check(){ for(auto x : par){ cout << x << " "; } cout << endl; } }; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, p; cin >> n >> p; UnionFind uf(n + 1); vector F(n + 1, true); for(int i = 2; i <= n; i++){ if(F[i]){ for(int j = i + i; j <= n; j += i){ uf.unite(i, j); F[j] = false; } } } cout << -uf.par[uf.root(p)] << endl; return 0; }