#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; std::vectorprimes, nums; for (LL i = 2; i <= N; ++i) { bool flag = true; for (LL j = 2; j * j <= i; ++j) { if (i % j == 0) { flag = false; break; } } if (flag) primes.push_back(i); } auto temp = decomposit_prime(P); for (auto t : temp) nums.push_back(t.first); std::vectorok; for (LL i : primes) { for (LL j : nums) { if (lcm(i, j) <= N) { ok.push_back(i); break; } } } LL ans = 0; for (LL i = 2; i <= N; ++i) { for (LL j : ok) { if (i % j == 0) { ++ans; break; } } } out << ans << std::endl; }