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