W = int(input()) D = int(input()) while D > 1: W -= int(W/(D*D)) D -= 1 print(W)