#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<> typedef long long ll; using namespace std; const ll mod= 1e9; ll dp[10010][10100]; int main(){ ll N, M; cin >> N >> M; N/=1000LL; N%=M; dp[0][0]=1; REP(i,0,M){ REP(j,0,N+1){ (dp[i+1][j] += dp[i][j]) %= mod; if(j+1<=N) (dp[i+1][j+1] += dp[i][j]) %= mod; } } p(dp[M][N]); return 0; }