#include using namespace std; typedef long long ll; ll ncr(int n, int r) { if (n / 2 < r) { r = n - r; } if (n == r || r == 0) { return 1; } else if (r == 1) { return n; } else { return (ncr(n - 1, r - 1) + ncr(n - 1, r))%1000000000; } } int main() { ll n; int m, m2; cin >> n >> m; m2 = n / 1000 % m; cout << ncr(m, m2) << endl; return 0; }