import math W= int(input()) D= int(input()) for i in range(D+1): today_W= math.floor(W / D**2) W= W - today_W print(W)