#include "bits/stdc++.h" #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i decomposit_prime(LL n) { LL d = 2; std::mapres; while (d * d <= n) { if (n % d == 0) { ++res[d]; n /= d; } else ++d; } ++res[n]; return res; } LL gcd(LL a, LL b) { if (a < b) std::swap(a, b); LL r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } int main() { LL N, P; in >> N >> P; auto primes = decomposit_prime(P); std::vectornums; for (auto i : primes) nums.push_back(i.first); std::sort(nums.begin(), nums.end()); LL ans = 0; for (LL i = 2; i <= N; ++i) { auto ps = decomposit_prime(i); for (auto j : ps) { if (lcm(nums[0], j.first) <= N) ++ans; break; } } out << ans << std::endl; }