#include using namespace std; typedef long long ll; typedef vector VI; typedef vector VVI; typedef vector VL; typedef vector VVL; typedef pair PII; #define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define MOD 1000000007 #define INF 1000000000 #define PI 3.14159265359 #define EPS 1e-12 ll dp[10010][10010]; int main(void) { ll n, m; cin >> n >> m; ll a = n%(m*1000)/1000; if(a == 0) { cout << 1 << endl; return 0; } //cout << a << endl; //m人にa枚を配る REP(i, m+1) { REP(j, i+1) { if(j == 0 || j == i) dp[i][j] = 1; else dp[i][j] = (dp[i-1][j-1] + dp[i-1][j])%INF; //cout << dp[i][j] << " "; } //cout << endl; } cout << dp[m][a]%INF << endl; return 0; }