n = int(input()) m = int(input()) for i in range(m - 1): w = n // ((m - i) ** 2) n -= w print(n)