w = int(raw_input()) d = int(raw_input()) while d > 1: w -= w / (d*d) d -= 1 print w