#include #include #include #include using namespace std; #define MOD 1000000000LL typedef long long LL; LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; } int main(int argc, char *argv[]) { string s; getline(cin, s); LL N, M; stringstream ss(s); ss >> N; getline(cin, s); M = atoi(s.c_str()); N /= 1000; N %= M; LL a[10000] = {}; for (LL i = 0; i < N; ++i) { a[i] = i + 1; } LL ans = 1; for (LL i = M-N+1; i <= M; ++i) { LL b = i; for (LL j = 0; j < N; ++j) { LL g = gcd(a[j], b); a[j] /= g, b /= g; } ans = (ans * b) % MOD; } cout << ans << endl; return 0; }