#include using namespace std; #define int long long signed main(){ int N, D; cin>> N>> D; int ans=0; int n=N; while(1){ ans+=(n/D); int mod=n%D; if(mod==0){ break; }else{ n=N+mod; } } cout<< ans-1<< endl; return 0; }