N,K,M = map(int,input().split()) C =10 ** 6 + 1 dat = [0] * C prime = dict() for i in range(2,C): if dat[i] == 0: for j in range(2 * i,C,i): dat[j] = 1 if M % i == 0: count = 0 while M % i == 0: count += 1 M //= i prime[i] = count if M != 1: prime[M] = 1 _min = 10 ** 9 def count(t,p): ans = 0 i = p while t // i: ans += t // i i *= p return ans for p in prime: a = count(N,p) b = count(K,p) c = count(N-K,p) d = a - b - c e = d // prime[p] if e < _min: _min = e print(_min)