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