n=int(input()) m=int(input()) l=(n//1000)//m k=n//1000-l*m M=10**9 c=[[0]*(m+1) for i in range(m+1)] c[0][0]=1 for i in range(m): for j in range(m): c[i+1][j]+=c[i][j] c[i+1][j]%=M c[i+1][j+1]+=c[i][j] c[i+1][j+1]%=M print(c[m][k])