#include #include using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) using mint = atcoder::modint998244353; ll dn(ll x,ll p){ ll rt=0; while(x>0){ rt+=x/p; x/=p; } return rt; } int main(){ ll n,p; cin>>n>>p; ll m=dn(n,p); cout<