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