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