#include #define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i) #define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i) #define ALL(t) t.begin(), t.end() #define RALL(t) t.rbegin(), t.rend() #define MATINIT(type, row, col, init) \ vector>(row, vector(col, init)); #define Yes(cond) cout << (cond ? "Yes" : "No") << endl; #define YES(cond) cout << (cond ? "YES" : "NO") << endl; using namespace std; using LL = long long; using ULL = unsigned long long; template using VEC = std::vector; template using MAT = std::vector>; void DUMP() { cerr << endl; } template void DUMP(Head &&head, Tail &&... tail) { cerr << head << ", "; DUMP(std::move(tail)...); } template ostream &operator<<(ostream &os, vector &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, set &s) { os << "{"; for (auto p : s) os << p << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, map &m) { os << "{"; for (auto p : m) os << p << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, pair p) { os << "[" << p.first << " " << p.second << "]"; return os; } std::map primeFactorization( long long n) { /* prime factorization * nを素因数分解する */ std::map pf; for (long long i = 2; i * i <= n; ++i) { while (n % i == 0) { n /= i; ++pf[i]; } } if (n > 1) { ++pf[n]; } return pf; } int N, P; const int MAX_N = 1e6; VEC used(MAX_N + 2, 0); void dfs(int p) { if (used[p]) return; // DUMP(p); used[p] = true; int i = 2; while (p * i <= N) { used[p * i] = true; if (i > 1) dfs(i); ++i; } } int main() { cin >> N >> P; auto pf = primeFactorization(P); for (auto v : pf) { int q = v.first; dfs(q); } dfs(P); DUMP(); int cnt = 0; REP(i, 1, N + 1) { if (used[i] == true) { // DUMP(i); ++cnt; } } cout << cnt << endl; return 0; }