import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip; immutable long MOD = 10^^9 + 7; void main() { auto s = readln.split.map!(to!long); auto N = s[0]; auto M = s[1]; auto X = N / M; if (X <= 1) { writeln(0); return; } long ans = X * (X - 1) % MOD; auto table = new bool[](N+1); for (long i = M * 2; i <= N; i += M) { if (table[i]) continue; ans -= 1L * (N / i) * (N / i - 1) % MOD; ans %= MOD; for (long j = i * 2; j <= N; j += i) { table[j] = true; } } foreach (i; 1..N-1) { ans = ans * i % MOD; } ans = (ans + MOD) % MOD; ans.writeln; }