#include #include using namespace std; typedef long long ll; ll mod = 1e9; struct Combination{ int n; vector> dp; Combination(int i){ n = i; dp = vector>(n+1, vector(n+1, 0)); constructTriangle(); } void constructTriangle(){ dp[0][0] = 1; for(int i = 1; i <= n; i++){ dp[i][0] = dp[i-1][0]; for(int j = 1; j <= i; j++){ dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % mod; } } } // return aCb ll getCombination(int a, int b){ return dp[a][b]; } }; int main(){ ll n, m; cin >> n >> m; n /= 1000; Combination c(m); cout << c.getCombination(m, n%m) << endl; return 0; }