/* * Author: nskybytskyi * Time: 2022-01-13 15:08:45 */ #include using namespace std; int main() { cin.tie(0)->sync_with_stdio(0); int64_t n, k, m; cin >> n >> k >> m; map pp; for (int64_t d = 2; d * d <= m; ++d) { while (m % d == 0) { ++pp[d]; m /= d; } } if (m > 1) { ++pp[m]; } auto nu = [&] (int64_t x, int64_t p) -> int64_t { int64_t ans = 0; while (x) { ans += x / p; x /= p; } return ans; }; int64_t mn = numeric_limits::max(); for (auto [key, val] : pp) { mn = min(mn, (nu(n, key) - nu(k, key) - nu(n - k, key)) / val); } cout << mn << "\n"; return 0; }