def f(): w,d = int(input()),int(input()) while d > 1: w,d = w-w//(d*d),d-1 return w print(f())