import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines W,D = map(int,read().split()) for d in range(D,1,-1): x = W // (d * d) W -= x print(W)