#include using namespace std; signed main(){ long long int w , d; cin >> w >> d; long long int rest = w; for( long long int i = d ; i >= 2 ; --i){ if( (i * i) > rest ) continue; else { rest -= static_cast(rest / ( i * i )); } } cout << rest << endl; }