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