def factorize(n): nn = n ret = [] p = 2 while p * p <= nn: e = 0 while nn % p == 0: nn //= p e += 1 if e > 0: ret.append((p, e)) p += 1 if nn > 1: ret.append((n, 1)) return ret def f(n, p): ret = 0 k = p while k <= n: ret += n // k k *= p return ret n, k, m = map(int, input().split()) pes = factorize(m) ans = 10 ** 100 for pe in pes: p, e = pe[0], pe[1] e2 = f(n, p) - f(n - k, p) - f(k, p) tmp = e2 // e ans = min(ans, tmp) print(ans)