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