import sys input = sys.stdin.readline N,K,M = map(int, input().split()) def prime_factorize(n): res = [] for i in range(2, int(n ** 0.5) + 1): cnt = 0 while(n % i == 0): n //= i cnt += 1 if(cnt > 0): res.append((i, cnt)) if(n > 1): res.append((n, 1)) return res def legendre(n,k,p): r = n - k res = 0 while(n): n //= p res += n while(k): k //= p res -= k while(r): r //= p res -= r return res ans = 10 ** 18 for p,c in prime_factorize(M): k = legendre(N,K,p) // c if(k < ans): ans = k print(ans)