n,k,m=map(int,input().split()) d={} v=m i=2 while i*i<=v: if v%i==0: d[i]=0 while v%i==0: d[i]+=1 v//=i i+=1 if v>1: d[v]=1 def solve(a,b): c=0 v=a u=b while v//u>0: c+=v//u u*=b return c print(min((solve(n,v)-solve(k,v)-solve(n-k,v))//d[v] for v in d))