mod = 10**9+7
n,k = map(int,input().split())
ans = 0
mod = 10**9 + 7
inv_t = [0,1]
for i in range(2,n+2):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]
a = n
b = n-1
for i in range(1,min(n,k)+1):
    ans += a*b % mod
    a = a*(n-i)*inv_t[i+1] % mod
    b = b*(n-i-1)*inv_t[i+1] % mod
    ans %= mod
if k > 1:
    ans += 1
print(ans % mod) mod = 10**9+7 mod 10**9+7 10**9 10 9 7 n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k ans = 0 ans 0 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 inv_t = [0,1] inv_t [0,1] 0 1 for i in range(2,n+2):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod] i range(2,n+2) range 2 n+2 n 2 inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod] inv_t [inv_t[mod % i] * (mod - int(mod / i)) % mod] inv_t[mod % i] * (mod - int(mod / i)) % mod inv_t[mod % i] * (mod - int(mod / i)) inv_t[mod % i] inv_t mod % i mod i mod - int(mod / i) mod int(mod / i) int mod / i mod i mod a = n a n b = n-1 b n-1 n 1 for i in range(1,min(n,k)+1):
    ans += a*b % mod
    a = a*(n-i)*inv_t[i+1] % mod
    b = b*(n-i-1)*inv_t[i+1] % mod
    ans %= mod i range(1,min(n,k)+1) range 1 min(n,k)+1 min(n,k) min n k 1 ans += a*b % mod ans a*b % mod a*b a b mod a = a*(n-i)*inv_t[i+1] % mod a a*(n-i)*inv_t[i+1] % mod a*(n-i)*inv_t[i+1] a*(n-i) a n-i n i inv_t[i+1] inv_t i+1 i 1 mod b = b*(n-i-1)*inv_t[i+1] % mod b b*(n-i-1)*inv_t[i+1] % mod b*(n-i-1)*inv_t[i+1] b*(n-i-1) b n-i-1 n-i n i 1 inv_t[i+1] inv_t i+1 i 1 mod ans %= mod ans mod if k > 1:
    ans += 1 k > 1 k 1 ans += 1 ans 1 print(ans % mod) print ans % mod ans mod inv_t = [0,1] [0,1] inv_t mod = 10**9+7 10**9+7 mod mod = 10**9 + 7 10**9 + 7 mod ans += 1 1 ans n,k = map(int,input().split()) map(int,input().split()) n ans += a*b % mod a*b % mod ans k = map(int,input().split()) map(int,input().split()) k b = b*(n-i-1)*inv_t[i+1] % mod b*(n-i-1)*inv_t[i+1] % mod b ans %= mod mod ans a = n n a inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod] [inv_t[mod % i] * (mod - int(mod / i)) % mod] inv_t ans = 0 0 ans b = n-1 n-1 b a = a*(n-i)*inv_t[i+1] % mod a*(n-i)*inv_t[i+1] % mod a
mod = 10**9+7
n,k = map(int,input().split())
ans = 0
mod = 10**9 + 7
inv_t = [0,1]
for i in range(2,n+2):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]
a = n
b = n-1
for i in range(1,min(n,k)+1):
    ans += a*b % mod
    a = a*(n-i)*inv_t[i+1] % mod
    b = b*(n-i-1)*inv_t[i+1] % mod
    ans %= mod
if k > 1:
    ans += 1
print(ans % mod)
