#include #define MOD 1000000000 #define MAX 10000 typedef long long ll; using namespace std; ll N, M; ll dp[MAX][MAX]; ll nCr(ll n, ll r) { if(n==r) return dp[n][r] = 1; if(r==0) return dp[n][r] = 1; if(r==1) return dp[n][r] = n; if(dp[n][r]) return dp[n][r]; return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1); } int main(void){ cin >> N >> M; ll noguchi = N / 1000; ll ans = 0; if(noguchi %= M){ ans = nCr(M, noguchi) % MOD; } else ans = 1; cout << ans << endl; return 0; }