#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[2][10100]; int main(){ ll N, M; cin >> N >> M; N /= 1000; N %= M; dp[0][0]=1; int from = 0; int to = 1; REP(i,0,M){ REP(j,0,N+1){ (dp[to][j] += dp[from][j]) %= mod; if(j+1<=N) (dp[to][j+1] += dp[from][j]) %= mod; } swap(from, to); REP(j,0,N+1) dp[to][j] = 0; } p(dp[from][N]); return 0; }