#include #define rep(i,n) for(int i=0; i< (n); i++) using namespace std; typedef long long ll; typedef pair P; const int mod = 998244353; const int inf = (1<<30); const ll INF = (1ull<<62); ll f(ll n,ll k){//k ha sosuu ll ans = 0; while(n > 0){ ans += n/k; n /= k; } return ans; } int main(){ ll n,k,m; cin>>n>>k>>m; ll t = n-k; ll ans = inf; for(ll i = 2; i*i <= m; i++){ if(m%i != 0) continue; int c = 0; while(m%i == 0){ m/=i; c++; } ans = min(ans,(f(n,i) - f(k,i) - f(t,i))/c); } if(m>1) ans = min(ans,(f(n,m) - f(k,m) - f(t,m))); cout<