#include <bits/stdc++.h>
using namespace std;
int count(long long a,long long b){
    long long temp=1;
    int ret=0;
    while(a/b>=temp){
        temp*=b;
        ret+=a/temp;
    }
    return ret;
}

int main(){
    long long N,K,M;
    int ans=INT_MAX,temp;
    cin>>N>>K>>M;
    map<long long,int> p;
    for(long long i=2;i*i<=M;++i){
        while(M%i==0){
            ++p[i];
            M/=i;
        }
    }
    if(M>1){
        ++p[M];
    }
    for(auto i=p.begin();i!=p.end();++i){
        temp=count(N,i->first)-count(K,i->first)-count(N-K,i->first);
        ans=min(ans,temp/i->second);
    }
    cout<<ans<<endl;
}