w = int(input()) d = int(input()) while(1): if d == 1: break w = w - (w // (d ** 2)) d -= 1 print(w)