#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(int i = m;i < n;++i) #define pb push_back #define fore(i,a) for(auto &i:a) #define rrep(i,m,n) for(int i = m;i >= n;--i) #define INF INT_MAX/2 using namespace std; using ll = long long; using R = double; using Data = pair>; const ll MOD = 1e9 + 7; const ll inf = 1LL << 50; struct edge { ll from; ll to; ll cost; }; ll comb[10010][10010]; void combinit() { for (int i = 0; i <= 10000; i++) { comb[i][0] = 1LL; comb[i][i] = 1LL; } for (int i = 1; i <= 10000; i++) { for (int j = 1; j <= i - 1; j++) { comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1])%MOD; } } } int main() { ll n, m; cin >> n >> m; combinit(); ll temp = n / 1000; if (temp <= m) { cout << comb[m][temp] << endl; } else { temp -= m * (temp / m); cout << comb[m][temp] << endl; } return 0; }