n, k = map(int, input().split()) mod = 10**9 + 7 # nは任意の数に置き換え可能 fact = [1] * (n + 1) inv = [1] * (n + 1) finv = [1] * (n + 1) for i in range(2, n + 1): fact[i] = fact[i - 1] * i % mod inv[i] = mod - inv[mod % i] * (mod // i) % mod finv[i] = finv[i - 1] * inv[i] % mod def comb(a, b): return fact[a] * finv[b] * finv[a - b] % mod def extgcd(a, b): if b != 0: d, y, x = extgcd(b, a % b) y -= (a // b) * x return d, x, y return a, 1, 0 def inverse(a, m): d, x, _ = extgcd(a, m) if d != 1: return -1 return x % m ans = 0 cnt = 1 if k - 1 >= n: for i in range(1, n + 1): cnt *= k - i + 1 cnt *= inv[i] cnt %= mod ans += cnt for i in range(1, n): if k + i > n: cnt *= k + i cnt *= inverse(k + i - n, mod) cnt %= mod ans += cnt * comb(n - 1, i) % mod ans %= mod elif k + i == n: ans += cnt * comb(n - 1, i) % mod ans %= mod print(ans)