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