#include #include #include #include #include #include #include #include #include // require sort next_permutation count __gcd reverse etc. #include // require abs exit atof atoi #include // require scanf printf #include #include // require accumulate #include // require fabs #include #include #include #include // require setw #include // require stringstream #include // require memset #include // require tolower, toupper #include // require freopen #include // require srand #define rep(i,n) for(int i=0;i<(n);i++) #define ALL(A) A.begin(), A.end() using namespace std; typedef long long ll; typedef pair P; const int MOD = (int)1e9; const int MAX_N = (int)1e4 + 4; int c[MAX_N][MAX_N]; void calc_comb (void ){ memset (c, 0, sizeof (c ) ); c[0][0] = 1; for (int i = 1; i < MAX_N; i++ ){ rep (j, i+1 ){ c[i-j][j] = (c[i-j][j] + (j > 0 ? c[i-j][j-1] : 0 ) ) % MOD; c[i-j][j] = (c[i-j][j] + (i - j > 0 ? c[i-j-1][j] : 0 ) ) % MOD; } // end rep } // end for /* rep (i, MAX_N ) { rep (j, MAX_N ){ cerr << c[i][j] << (j != MAX_N - 1 ? ' ' : '\n' ); } // end rep } // end rep */ } int comb (int n, int m ){ if (n < m ) swap (n, m ); return c[n-m][m]; } int main() { calc_comb (); ios_base::sync_with_stdio(0); ll N, M; cin >> N >> M; N /= 1000LL; int res = 0; if (N % M == 0LL ){ res = 1; }else{ res = comb((int)M, (int)(N % M ) ); } // end if cout << res << endl; return 0; }