#include #include #include #include #include #include #include #include #include #include #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define P pair #define MOD 1000000007 #define INF 1012345678 #define NINF (-2147483647-1) #define LLINF 9223372036854775807 using ll = long long; using namespace std; // combination ll comb(ll n, ll r) { vector> v(n + 1, vector(n + 1, 0)); for (ll i = 0; i < (ll)v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (ll j = 1; j < (ll)v.size(); j++) { for (ll k = 1; k < j; k++) { v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % 1000000000; } } return v[n][r]; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N,M; cin >> N >> M; cout << comb(M, N / 1000 % M) << endl; getchar(); getchar(); }