N, M = map(int, input().split()) MOD = 10 ** 9 + 7 for x in range(1, M + 1): d, m = divmod(N + 1, x) ans = pow(d + 1, m, MOD) * pow(d, x - m - 1, MOD) * (d - 1) ans %= MOD print(ans)