N, M = map(int, input().split()) class facmod: def __init__(self, N: int, md: int) -> None: assert N < md self.md = md self.facs = [1] * (N + 1) self.facinvs = [1] * (N + 1) for i in range(1, N + 1): self.facs[i] = self.facs[i - 1] * i % md self.facinvs[N] = pow(self.facs[i], md - 2, md) for i in range(N - 1, 0, -1): self.facinvs[i] = self.facinvs[i + 1] * (i + 1) % md def nCr(self, n: int, r: int) -> int: if n < 0 or r < 0 or n < r: return 0 return (self.facs[n] * self.facinvs[r]) % md * self.facinvs[n - r] % md md = 1000000007 fac = facmod(1000000, md) ncrs = [fac.nCr(N, i) for i in range(N + 1)] ncr_cums = [0] * (N + 2) for i in range(N + 1): ncr_cums[i + 1] = ncr_cums[i] + ncrs[i] if ncr_cums[i + 1] >= md: ncr_cums[i + 1] -= md ret = 0 def add_closed(l: int, r: int) -> None: global ret if l > r: return ret += ncr_cums[(r if r < N else N) + 1] - ncr_cums[l if l >= 0 else 0] for h in range(1, N + 1): if M - (N - M) >= h: add_closed(M, N) else: l = h + (N - h + 1) // 2 add_closed(l, N) add_closed(l + 1 - ((N - h) & 1), l + l - M - ((N - h) & 1)) K = N - M for h in range(1, K + 1): l = h + (N - h + 1) // 2 if l <= K: add_closed(l, K) add_closed(l + 1 - ((N - h) & 1), N) else: add_closed(h + N - K, N) for i in range(M, N + 1): ret += fac.nCr(N, i) * N print(ret % md)