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