a=int(input()) b=int(input()) l=[] l.append(a) for i in range(b,0,-1): a-=(a//(i*i)) l.append(a) if b==1: print(l[0]) exit() print(l[-2])