#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b makePrimes(int n) { // [2,n] vector res, pr(n + 1, 1); pr[0] = pr[1] = 0; rep(p, 2, sqrt(n) + 2) if (pr[p]) for (int x = p * 2; x <= n; x += p) pr[x] = 0; rep(p, 2, n + 1) if (pr[p]) res.push_back(p); return res; } /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N, P; int vis[1010101]; vector EP[1010101]; //--------------------------------------------------------------------------------------------------- void _main() { cin >> N >> P; auto primes = makePrimes(N); fore(p, primes) for (int x = p; x <= N; x += p) EP[x].push_back(p); int ans = 0; queue que; vis[P] = 1; que.push(P); while (!que.empty()) { int cu = que.front(); que.pop(); ans++; fore(p, EP[cu]) { int to = cu / p; if (1 < to and !vis[to]) { vis[to] = 1; que.push(to); } } fore(p, primes) { int to = p * cu; if (N < to) break; if (!vis[to]) { vis[to] = 1; que.push(to); } } } cout << ans << endl; }