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