import math N = int(input()) M = int(input()) def ncr(n, r): f = math.factorial return f(n) // f(r) // f(n - r) def floor(src, p=1000): return int(src / p) * p a, b = divmod(N, 1000*M) if b == 0: print(1) else: surplus = floor(b) if surplus < 1000: print(1) else: ans = ncr(M, surplus//1000) print(ans%1000000000)