#include <bits/stdc++.h>
using namespace std;
const long long INF = 3000000000000000000;
long long f(long long a, long long b){
  long long ans = 0;
  while (a > 0){
    a /= b;
    ans += a;
  }
  return ans;
}
int main(){
  long long N, K, M;
  cin >> N >> K >> M;
  vector<pair<long long, int>> P;
  for (long long i = 2; i * i <= M; i++){
    if (M % i == 0){
      int cnt = 0;
      while (M % i == 0){
        M /= i;
        cnt++;
      }
      P.push_back(make_pair(i, cnt));
    }
  }
  if (M > 1){
    P.push_back(make_pair(M, 1));
  }
  int cnt = P.size();
  long long ans = INF;
  for (int i = 0; i < cnt; i++){
    long long p = P[i].first;
    ans = min(ans, (f(N, p) - f(K, p) - f(N - K, p)) / P[i].second);
  }
  cout << ans << endl;
}