#include<iostream> using namespace std; int main(){ int k,n,s=0,m=0; cin>>n>>k; while(n){ s+=n; m+=n; n=m/k; m=m%k; } cout<<s; return 0; }