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