#include using namespace std; int main(int argc, char *argv[]) { int64_t N, P; cin >> N >> P; if (P == 1) { cout << 1 << endl; return 0; } vector arr; for (int i = 2; i * i <= P; i++) { if (P % i == 0) { arr.push_back(i); P /= i; } } if (P > 1) { arr.push_back(P); } // そうでない場合、最小の素因数の倍数 // を全て答えにする(掛けた数も含む) sort(arr.begin(), arr.end()); int base = arr[0]; set s; for (int j = 1; j * base <= N; j++) { int one = j * base; int other = j; if (one != 1) s.insert(j * base); if (other != 1) s.insert(other); } cout << s.size() << endl; return 0; }