N = int(input()) M = int(input()) a = N//1000//M b = N - (a * M) * 1000 c = b//1000 def pascal2(n, k): p = [0 for _ in range(n+1)] p[0] = 1 for x in range(1, n+1): for y in range(n, 0, -1): p[y] = (p[y-1] + p[y])%1000000000 return p[k] print(pascal2(M, c)%1000000000)