import std.algorithm, std.array, std.container, std.range; import std.string, std.conv; import std.math, std.bigint, std.bitmanip, std.random; import std.stdio, std.typecons; const auto mod = 10^^9; void main() { auto n = readln.chomp.to!long / 1000; auto m = readln.chomp.to!long; auto a = n - (n / m) * m; writeln(combination(m, a)); } long combination(long n, long r) { auto memo = new long [][](n + 1); memo[0] = [1]; foreach (i; 1..n + 1) { memo[i] = new long[](i + 1); memo[i][0] = 1; memo[i][i] = 1; foreach (j; 1..i) { memo[i][j] = (memo[i - 1][j - 1] + memo[i - 1][j]) % mod; } } return memo[n][r]; }