n = int(input()) m = int(input()) while m >= 1: if m == 1: print(n) a = n / m ** 2 a = int(a) n = n - a m -= 1