#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) vector > dp(10001); int main(){ long long n, m; cin >> n >> m; n /= 1000; n %= m; dp[1].push_back(1); dp[1].push_back(1); FOR(i,1,10000){ FOR(j,0,i+2){ if(j == 0) dp[i+1].push_back(dp[i][j]); else if(j == i) dp[i+1].push_back(dp[i][i-1]); else dp[i+1].push_back(dp[i][j-1] + dp[i][j]); dp[i+1][j] %= 1000000000; } } if(n==0){ cout << 1 << endl; } else { cout << dp[n][m] << endl; } return 0; }