w=int(input()) d=int(input()) for i in range(d,1,-1): n=w//(i*i) w-=n print(w)