N = int(input()) M = int(input()) MOD = 10**9 N = N//1000 r = N%M dp = [[0 for _ in range(r+1)] for _ in range(M+1)] for i in range(M+1): dp[i][0] = 1 if r>0: for i in range(1,M+1): dp[i][1] = i for i in range(2,M+1): for j in range(2,r+1): if j>i:break dp[i][j] = (dp[i-1][j]+dp[i-1][j-1])%MOD print(dp[M][r])