#include<bits/stdc++.h>
using namespace std;
ifstream fi("MAXNUM.inp");
ofstream fo("MAXNUM.out");
int main(){
   int p,n,m=0,t=1,tg;
   fi>>n>>p;
   for(int i=1;i<=n;++i){
      tg=i;
      while(tg%p==0){m++;tg/=p;}
      if(tg%p!=0)t*=tg;
      if(t%p==0){m++;t/=p;}
   }
fo<<m;
}
