// #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int inf=1<<30; const ll INF=1LL<<62; typedef pair P; typedef pair PP; const ll MOD=998244353; const int dy[]={0,1,0,-1}; const int dx[]={1,0,-1,0}; int main(){ ll N,K,M; cin>>N>>K>>M; auto n_fact=[&](ll n){ //nの素因数分解 map res; for(ll d=2;d*d<=n;d++){ while(n%d==0){ res[d]++; n/=d; } } if(n!=1) res[n]++; vector> v; for(auto p:res){ v.push_back(p); } return v; }; auto divide=[&](ll n,ll k){ //n!は kで何回割れるか? ll res=0; while(n>0){ res+=n/k; n/=k; } return res; }; ll ans=INF; for(auto p:n_fact(M)){ ll num=0; num+=divide(N,p.first);//N!はMで何回割れるか? num-=divide(K,p.first);//K!はMで何回割れるか? num-=divide(N-K,p.first);//(N-K)!はMで何回割れるか? num = (num+p.second-1)/p.second; ans=min(ans,num); } cout<