#include #include using namespace std; struct SieveEratos{ vector t; SieveEratos(int n):t(n+1,true){ t[0] = t[1] = false; for(int i = 2; n >= i; i++){ if(t[i]){ for(int j = i+i; n >= j; j+=i){ t[j] = false; } } } } bool operator[](int x){return t[x];} }; const int mod = 1000000000; long long C(int n,int r,vector P){ //nCr = nC(n-r) if(r > n/2)r = n-r; int a[n];for(int i = 0; r > i; i++)a[i] = n-i; for(int p:P){ //素数p > rだったらforに入らないので if(p > r)break; for(int q = p; r >= q; q *= p){ int m = n%q; for(int i = m, j = 0; r/q > j;i+=q,j++){ //cout << i << " " << p << endl; a[i]/=p; } } } long mul = 1; for(int i = 0; r > i; i++){ //cout << a[i] << " "; mul = (mul*a[i])%mod; } //cout << endl; return mul; } int main(){ vector P; SieveEratos A(10000); for(int i = 0; 10000 > i; i++){ if(A[i])P.push_back(i); } long long n,m;cin>>n>>m; n = n/1000; int N = m; int R = n%m; cout << C(N,R,P) << endl; }