W=int(input());D=int(input()) while D!=1: W=W-(W//(D**2));D-=1 print(W)