#include using namespace std; using ll = long long; bool is_prime(int n) { if (n % 2 == 0) return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return n != 1; } vector divisor(int n) { vector res; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { res.emplace_back(i); if (i != n / i) res.emplace_back(n / i); } } return res; } map prime_factor(int n) { map res; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { ++res[i]; n /= i; } } if (n != 1) res[n] = 1; return res; } vector sieve(int n) { vector res; vector is_prime(n + 1, true); is_prime[0] = false; is_prime[1] = false; for (int i = 2; i <= n; i++) { if (!is_prime[i]) continue; res.emplace_back(i); for (int j = 2 * i; j <= n; j += i) is_prime[j] = false; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, p; cin >> n >> p; if (p == 1) { cout << 1 << endl; return 0; } vector s = sieve(n); map pf = prime_factor(p); ll hoge = pf.begin()->first; vector ok(n + 1, false); for (auto& p : pf) ok[p.first] = true; for (int x : s) { if (!ok[x] && x * hoge > n) continue; ok[x] = true; for (int i = 2 * x; i <= n; i += x) { ok[i] = true; } } int ans = 0; for (int i = 1; i <= n; i++) { ans += ok[i]; } cout << ans << endl; return 0; }