import math W = int(input()) D = int(input()) def motivate(w, d): if d <= 1: print(w) else: motivate(w - math.floor(w / (d ** 2)), d - 1) motivate(W, D)