#include int work(int w, int d) { int a=w-(int)(w/d/d); return ((d==1)?w:work(a,d-1)); } int main() { int w,d; std::cin >> w >> d; std::cout << work(w,d) << std::endl; }