#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector VI; typedef pair PI; const double EPS=1e-9; const int N = 10010; int a[N]; int main(void){ ll n,m; cin >> n >> m; n /= 1000; n %= m; // C(m, n) REP(i, 0, n) { a[i] = m - i; } REP(i, 2, n + 1) { REP(j, 0, n) { if (a[j] % i == 0) { a[j] /= i; break; } } } ll sum = 1; const ll mod = 1e9; REP(i, 0, n) { sum *= a[i]; sum %= mod; } cout << sum << endl; }