#include<bits/stdc++.h> using namespace std; int main(){ int n,k,sum; cin>>n>>k; sum=n; while(n/k>=1){ sum+=n/k; n/=k; } cout<<sum; return 0; }