#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; vector sieve(int n) { vector f(n + 1); for (int i = 3; i <= n; i += 2) f[i] = 1; for (int i = 3; i <= sqrt(n); i += 2) if (f[i]) for (int j = i * 3; j <= n; j += i) f[j] = 0; vector res; if (n >= 2)res.push_back(2); for (int i = 3; i <= n; i += 2) if (f[i]) res.push_back(i); return res; } vi ps[1000006], qs[1000006]; int vp[1000006], vq[1000006]; void solve() { int N, P; cin >> N >> P; auto primes = sieve(N); each(p, primes) { for (int i = 1; i*p <= N; ++i) { ps[i*p].push_back(p); qs[p].push_back(i*p); } } int ans = 0; queue Q; Q.push(P); vp[P] = 1; while (!Q.empty()) { int n = Q.front(); Q.pop(); ans++; each(p, ps[n]) { if (!vq[p]++) { each(m, qs[p]) { if (!vp[m]++) { Q.push(m); } } } } } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }