#include using namespace std; typedef long long ll; #include #include using namespace std; typedef long long ll; const ll MOD = 1e9; const int sz = 2; const int mod_ps[sz] = {2, 5}; const int mod_pk[sz] = {512, 1953125}; ll fact[sz][2000000]; void init(){ for(int i=0;i>=1){ if(e&1){ v = (v * x) % m; } x = (x * x) % m; } return v; } ll mod_fact(int n, int i, int p, int pk, int &e1, int &e2){ e1 = e2 = 0; if(n == 0)return 1; ll res = mod_fact(n / p, i, p, pk, e1, e2); e1 += n / p; e2 += n / pk; res = res * fact[i][n % pk] % pk; return res; } pair linear_congruence(const vector& A, const vector &B, const vector& M){ ll x = 0, m = 1; for(int i=0;i A(sz, 1); vector B(sz), M(sz); for(int i=0;i ps = linear_congruence(A, B, M); return ps.first; } int main(){ init(); ll N, M; cin >> N >> M; N /= 1000; N %= M; cout << C(M, N) << endl; return 0; }