#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int MOD = 1000000000; void combination(int n, vector& comb) { comb.assign(2, 0); comb[0] = 1; for(int i=1; i<=n; ++i){ vector tmp(i+2, 0); tmp[0] = 1; for(int j=1; j<=i; ++j){ tmp[j] = comb[j-1] + comb[j]; tmp[j] %= MOD; } comb.swap(tmp); } } int main() { long long n, m; cin >> n >> m; vector comb; combination(m, comb); cout << comb[n / 1000 % m] << endl; return 0; }