#include using namespace std; int64_t count(int64_t n, int64_t p) { if (n == 0) { return 0; } return n / p + count(n / p, p); } int main() { int64_t n, k, m; cin >> n >> k >> m; map primes; for (int64_t i = 2; i * i <= m; i++) { while (m % i == 0) { primes[i]++; m /= i; } } if (m > 1) { primes[m]++; } int64_t ans = 1e9; for (auto &&[p, c] : primes) { ans = min(ans, (count(n, p) - count(k, p) - count(n - k, p)) / c); } cout << ans << endl; return 0; }