from collections import defaultdict as dd
N,k = map(int, input().split())

# 0人の部屋がt個あるとすると、n-t個の部屋にn人がいる。
# k!=1のとき0<=t<=min(k, n-1)
# k==1のときt=1
res = 0
fact = [0]*(N+1)
ifact = [0]*(N+1)
inv = [0]*(N+1)
p=10**9+7

dic = dd(int)

def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p
def op(n,k):
    if (n,k) in dic.keys():
        return dic[(n,k)]
    if k<0 or k>n or n<0:
        return 0
    dic[(n,k)] = (fact[n]*ifact[k]*ifact[n-k])%(10**9+7)
    return dic[(n,k)]

combination(N,fact,ifact)
for t in range(0, min(k, N-1)+1):
    # n-t個の部屋にn人を入れる。ただし、どの部屋にも1人以上いる必要がある
    # n個の部屋のうちどのt個を0人にするかでnCt
    # n-t個の部屋の人数でn-1Cn-t-1
    res += (op(N-1, N-t-1) * op(N, t))%p
print(res%p) from collections import defaultdict as dd N,k = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split k res = 0 res 0 fact = [0]*(N+1) fact [0]*(N+1) [0] 0 N+1 N 1 ifact = [0]*(N+1) ifact [0]*(N+1) [0] 0 N+1 N 1 inv = [0]*(N+1) inv [0]*(N+1) [0] 0 N+1 N 1 p=10**9+7 p 10**9+7 10**9 10 9 7 dic = dd(int) dic dd(int) dd int def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p combination fact[0] = 1 fact[0] fact 0 1 fact[1] = 1 fact[1] fact 1 1 ifact[0] = 1 ifact[0] ifact 0 1 ifact[1] = 1 ifact[1] ifact 1 1 inv[1] = 1 inv[1] inv 1 1 for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p i range(2,n+1) range 2 n+1 n 1 fact[i] = (fact[i-1]*i)%p fact[i] fact i (fact[i-1]*i)%p fact[i-1]*i fact[i-1] fact i-1 i 1 i p inv[i] = p - inv[p%i]*(p//i)%p inv[i] inv i p - inv[p%i]*(p//i)%p p inv[p%i]*(p//i)%p inv[p%i]*(p//i) inv[p%i] inv p%i p i p//i p i p ifact[i] = (ifact[i-1]*inv[i])%p ifact[i] ifact i (ifact[i-1]*inv[i])%p ifact[i-1]*inv[i] ifact[i-1] ifact i-1 i 1 inv[i] inv i p n n fact fact ifact ifact def op(n,k):
    if (n,k) in dic.keys():
        return dic[(n,k)]
    if k<0 or k>n or n<0:
        return 0
    dic[(n,k)] = (fact[n]*ifact[k]*ifact[n-k])%(10**9+7)
    return dic[(n,k)] op if (n,k) in dic.keys():
        return dic[(n,k)]
     (n,k) in dic.keys() (n,k) n k dic.keys() dic.keys dic keys return dic[(n,k)] dic[(n,k)] dic (n,k) n k if k<0 or k>n or n<0:
        return 0
     k<0 or k>n or n<0 k<0 or k>n k<0 k 0 k>n k n n<0 n 0 return 0 0 dic[(n,k)] = (fact[n]*ifact[k]*ifact[n-k])%(10**9+7) dic[(n,k)] dic (n,k) n k (fact[n]*ifact[k]*ifact[n-k])%(10**9+7) fact[n]*ifact[k]*ifact[n-k] fact[n]*ifact[k] fact[n] fact n ifact[k] ifact k ifact[n-k] ifact n-k n k 10**9+7 10**9 10 9 7 return dic[(n,k)] dic[(n,k)] dic (n,k) n k n n k k combination(N,fact,ifact) combination N fact ifact for t in range(0, min(k, N-1)+1):
    # n-t個の部屋にn人を入れる。ただし、どの部屋にも1人以上いる必要がある
    # n個の部屋のうちどのt個を0人にするかでnCt
    # n-t個の部屋の人数でn-1Cn-t-1
    res += (op(N-1, N-t-1) * op(N, t))%p t range(0, min(k, N-1)+1) range 0 min(k, N-1)+1 min(k, N-1) min k N-1 N 1 1 res += (op(N-1, N-t-1) * op(N, t))%p res (op(N-1, N-t-1) * op(N, t))%p op(N-1, N-t-1) * op(N, t) op(N-1, N-t-1) op N-1 N 1 N-t-1 N-t N t 1 op(N, t) op N t p print(res%p) print res%p res p def op(n,k):
    if (n,k) in dic.keys():
        return dic[(n,k)]
    if k<0 or k>n or n<0:
        return 0
    dic[(n,k)] = (fact[n]*ifact[k]*ifact[n-k])%(10**9+7)
    return dic[(n,k)] def op(n,k):
    if (n,k) in dic.keys():
        return dic[(n,k)]
    if k<0 or k>n or n<0:
        return 0
    dic[(n,k)] = (fact[n]*ifact[k]*ifact[n-k])%(10**9+7)
    return dic[(n,k)] op res += (op(N-1, N-t-1) * op(N, t))%p (op(N-1, N-t-1) * op(N, t))%p res inv = [0]*(N+1) [0]*(N+1) inv N,k = map(int, input().split()) map(int, input().split()) N k = map(int, input().split()) map(int, input().split()) k res = 0 0 res fact = [0]*(N+1) [0]*(N+1) fact def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p combination p=10**9+7 10**9+7 p ifact = [0]*(N+1) [0]*(N+1) ifact dic = dd(int) dd(int) dic
from collections import defaultdict as dd
N,k = map(int, input().split())

# 0人の部屋がt個あるとすると、n-t個の部屋にn人がいる。
# k!=1のとき0<=t<=min(k, n-1)
# k==1のときt=1
res = 0
fact = [0]*(N+1)
ifact = [0]*(N+1)
inv = [0]*(N+1)
p=10**9+7

dic = dd(int)

def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p
def op(n,k):
    if (n,k) in dic.keys():
        return dic[(n,k)]
    if k<0 or k>n or n<0:
        return 0
    dic[(n,k)] = (fact[n]*ifact[k]*ifact[n-k])%(10**9+7)
    return dic[(n,k)]

combination(N,fact,ifact)
for t in range(0, min(k, N-1)+1):
    # n-t個の部屋にn人を入れる。ただし、どの部屋にも1人以上いる必要がある
    # n個の部屋のうちどのt個を0人にするかでnCt
    # n-t個の部屋の人数でn-1Cn-t-1
    res += (op(N-1, N-t-1) * op(N, t))%p
print(res%p)