#include using namespace std; class ld{ public: long ldc(long w,long d); }; long ld::ldc(long w,long d){ if(d==1){ return long ((w/d*d)); }else{ ldc(w-long((w/(d*d))),d-1); } } int main() { ld l; int w,d; cin >> w >> d; cout << l.ldc(w,d) << endl; return 0; }