#include using namespace std; using ll=long long; constexpr int mod=998244353; long long modpow(long long a,int n){ long long ret=1,t=a; for(int i=0;i<30;i++){ if(n>>i&1)ret=ret*t%mod; t=t*t%mod; } return ret; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N,P; cin>>N>>P; int cnt=0; while(N>0){ cnt+=N/P; N/=P; } cout<