#include using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < n; ++i) #define P pair #define Graph vector> #define fi first #define se second #define vvvvll vector>>> #define vvvll vector>> #define vvll vector> #define vll vector #define pqll priority_queue #define pqllg priority_queue, greater> constexpr ll INF = (1ll << 60); constexpr ll mod = 1000000000; // constexpr ll mod = 998244353; // constexpr ll mod = 67280421310721; constexpr double pi = 3.14159265358979323846; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } void pt_vvll(vvll v) { ll vs = v.size(), vs0 = v[0].size(); rep(i, vs) { rep(j, vs0) { cout << v[i][j]; if (j != vs0 - 1) cout << " "; else cout << "\n"; } } } void pt_vll(vll v) { ll vs = v.size(); rep(i, vs) { cout << v[i]; if (i == vs - 1) cout << "\n"; else cout << " "; } } ll combi(ll N, ll K) { ll ret = 1; rep(i, K) { ret = ret * (N - i) / (i + 1); ret %= mod; } return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N, M; cin >> N >> M; N -= (N / M / 1000 * 1000) * M; N /= 1000; // cout << N << "\n"; cout << combi(M, N) << "\n"; return 0; }