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