#include #include using namespace std; int num = 1e9; long long combination(long long m, long long i) { if (i == 0 || i == m) return 1; if (i == 1) return m; return combination(m - 1, i - 1) + combination(m - 1, i); } int main() { long long n, m; cin >> n >> m; while (n >= m * 1000) n -= m * 1000; long long i = 0; while (n >= 1000) { n -= 1000; i++; } cout << combination(m, min(i, m-i)) % num << endl; }