# coding:utf-8 N = int(input()) M = int(input()) a = N//1000//M b = N - (a * M) * 1000 c = b//1000 # def perm(n, k): # result = 1 # for i in range(1, k + 1): # result *= (n - i + 1) # result //= i # return result def pascal(n, k): z = n +1 p = [[0 for i in range(z)] for j in range(z)] for k in range(z): p[k][k] = 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 p[x-1][y-1] = 0 return p # print(M, c, perm(M, c)) # print(perm(M, c)%1000000000) # print(pascal(M, c)) print(pascal(M, c)[M][c]%1000000000)