import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N,K,M = map(int, input().split())
CP = collections.Counter(prime_factorize(M))
L = []
for k,v in CP.items():
    L.append(k)

def func(N):
    C = collections.Counter()
    for l in L:
        i = 1
        while l**i<=N:
            C[l]+=N//(l**i)
            i+=1
    return C

CNK =  func(N)-func(N-K)-func(K)
ans = 10**20
for l in L:
    ans = min(ans,CNK[l]//CP[l])
print(ans)