#include #include using namespace std; int mod = 1e9; int m; int dp[10001][10001]; void PascalsTriangle() { dp[1][1] = 1; for (int i = 2; i <= m + 1; i++) { for (int j = 1; j <= i; j++) { if (j > 1) { dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mod; } else { dp[i][j] = dp[i - 1][j] % mod; } } } } int main() { long long n; cin >> n >> m; n = (n % (m * 1000)) / 1000; if (n == 0) { cout << 1 << endl; return 0; } PascalsTriangle(); cout << dp[m + 1][min(n, m - n) + 1] << endl; }