MOD = 10**9+7
n, k = map(int, input().split())

def init_mod_c(lim=10**6, mod=10**9+7):
    fact = [1, 1] + [0] * (lim-1)
    fact_inv = [1, 1] + [0] * (lim-1)
    inv = [0, 1] + [0] * (lim-1)
    
    for i in range(2, lim+1):
        fact[i] = fact[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod

    def mod_c(n, m):
        if n < m or n < 0 or m < 0: return 0
        return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod

    return mod_c

ans = 1
comb = init_mod_c()
for i in range(1, min(k, n-1)+1):
    ans += comb(n, i) * comb(n-1, i)
    ans %= MOD
print(ans) 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 def init_mod_c(lim=10**6, mod=10**9+7):
    fact = [1, 1] + [0] * (lim-1)
    fact_inv = [1, 1] + [0] * (lim-1)
    inv = [0, 1] + [0] * (lim-1)
    
    for i in range(2, lim+1):
        fact[i] = fact[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod

    def mod_c(n, m):
        if n < m or n < 0 or m < 0: return 0
        return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod

    return mod_c init_mod_c fact = [1, 1] + [0] * (lim-1) fact [1, 1] + [0] * (lim-1) [1, 1] 1 1 [0] * (lim-1) [0] 0 lim-1 lim 1 fact_inv = [1, 1] + [0] * (lim-1) fact_inv [1, 1] + [0] * (lim-1) [1, 1] 1 1 [0] * (lim-1) [0] 0 lim-1 lim 1 inv = [0, 1] + [0] * (lim-1) inv [0, 1] + [0] * (lim-1) [0, 1] 0 1 [0] * (lim-1) [0] 0 lim-1 lim 1 for i in range(2, lim+1):
        fact[i] = fact[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod

     i range(2, lim+1) range 2 lim+1 lim 1 fact[i] = fact[i - 1] * i % mod fact[i] fact i fact[i - 1] * i % mod fact[i - 1] * i fact[i - 1] fact i - 1 i 1 i mod inv[i] = mod - inv[mod % i] * (mod//i) % mod inv[i] inv i mod - inv[mod % i] * (mod//i) % mod mod inv[mod % i] * (mod//i) % mod inv[mod % i] * (mod//i) inv[mod % i] inv mod % i mod i mod//i mod i mod fact_inv[i] = fact_inv[i - 1] * inv[i] % mod fact_inv[i] fact_inv i fact_inv[i - 1] * inv[i] % mod fact_inv[i - 1] * inv[i] fact_inv[i - 1] fact_inv i - 1 i 1 inv[i] inv i mod def mod_c(n, m):
        if n < m or n < 0 or m < 0: return 0
        return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod

     mod_c if n < m or n < 0 or m < 0: return 0
         n < m or n < 0 or m < 0 n < m or n < 0 n < m n m n < 0 n 0 m < 0 m 0 return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) fact[n] fact n fact_inv[m] * fact_inv[n-m] % mod fact_inv[m] * fact_inv[n-m] fact_inv[m] fact_inv m fact_inv[n-m] fact_inv n-m n m mod mod n n m m return mod_c mod_c lim=10**6 lim 10**6 10 6 mod=10**9+7 mod 10**9+7 10**9 10 9 7 ans = 1 ans 1 comb = init_mod_c() comb init_mod_c() init_mod_c for i in range(1, min(k, n-1)+1):
    ans += comb(n, i) * comb(n-1, i)
    ans %= MOD i range(1, min(k, n-1)+1) range 1 min(k, n-1)+1 min(k, n-1) min k n-1 n 1 1 ans += comb(n, i) * comb(n-1, i) ans comb(n, i) * comb(n-1, i) comb(n, i) comb n i comb(n-1, i) comb n-1 n 1 i ans %= MOD ans MOD print(ans) print ans ans = 1 1 ans n, k = map(int, input().split()) map(int, input().split()) n comb = init_mod_c() init_mod_c() comb MOD = 10**9+7 10**9+7 MOD ans += comb(n, i) * comb(n-1, i) comb(n, i) * comb(n-1, i) ans ans %= MOD MOD ans k = map(int, input().split()) map(int, input().split()) k def init_mod_c(lim=10**6, mod=10**9+7):
    fact = [1, 1] + [0] * (lim-1)
    fact_inv = [1, 1] + [0] * (lim-1)
    inv = [0, 1] + [0] * (lim-1)
    
    for i in range(2, lim+1):
        fact[i] = fact[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod

    def mod_c(n, m):
        if n < m or n < 0 or m < 0: return 0
        return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod

    return mod_c def init_mod_c(lim=10**6, mod=10**9+7):
    fact = [1, 1] + [0] * (lim-1)
    fact_inv = [1, 1] + [0] * (lim-1)
    inv = [0, 1] + [0] * (lim-1)
    
    for i in range(2, lim+1):
        fact[i] = fact[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod

    def mod_c(n, m):
        if n < m or n < 0 or m < 0: return 0
        return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod

    return mod_c init_mod_c
MOD = 10**9+7
n, k = map(int, input().split())

def init_mod_c(lim=10**6, mod=10**9+7):
    fact = [1, 1] + [0] * (lim-1)
    fact_inv = [1, 1] + [0] * (lim-1)
    inv = [0, 1] + [0] * (lim-1)
    
    for i in range(2, lim+1):
        fact[i] = fact[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod

    def mod_c(n, m):
        if n < m or n < 0 or m < 0: return 0
        return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod

    return mod_c

ans = 1
comb = init_mod_c()
for i in range(1, min(k, n-1)+1):
    ans += comb(n, i) * comb(n-1, i)
    ans %= MOD
print(ans)
