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