W = int(input()) D = int(input()) for i in range(D-1): work = int(W / (D ** 2)) D -= 1 W -= work print(W)