#include #define rep(i, a, n) for(int i = a; i < n; i++) #define int long long using namespace std; typedef pair P; const int mod = 1000000007; const int INF = 1e18; struct UF{ vector par, sz; UF(){} UF(int n):par(n), sz(n, 1){ iota(par.begin(), par.end(), 0); } int find(int x){ if(x == par[x]) return x; return par[x] = find(par[x]); } void unite(int x, int y){ x = find(x); y = find(y); if(x == y) return; if(sz[x] < sz[y]) swap(x, y); sz[x] += sz[y]; par[y] = x; } bool same(int x, int y){ return find(x) == find(y); } }; signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, p; cin >> n >> p; UF uf(n + 1); for(int i = 2; i <= n; i++){ if(uf.find(i) != i) continue; for(int j = 2 * j; j <= n; j += i){ uf.unite(i, j); } } cout << uf.sz[uf.find(p)] << endl; }