def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp
def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m)

n,k = map(int, open(0).read().split())
dp = [0] * n
dp[0] = 1
m = 1000000007
dp[1] = (n * (n-1)) % m
memf = []
mfappend = memf.append
for x in memfact(n,m):
    mfappend(x)
for i in range(2,min(k+1,n)):
    dp[i] = (dp[i-1]+comb(n,i,m)*comb(n-1,i,m)) % m
print((dp[min(n-1,k)]+1)%m) def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp memfact temp = 1 temp 1 yield temp temp for i in range(1,a+1):
        temp = temp * i % m
        yield temp i range(1,a+1) range 1 a+1 a 1 temp = temp * i % m temp temp * i % m temp * i temp i m yield temp temp a a m m def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m) comb if r == 0: return 1
     r == 0 r 0 return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m) memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m) memf[n]*pow(memf[r],m-2,m) memf[n] memf n pow(memf[r],m-2,m) pow memf[r] memf r m-2 m 2 m pow(memf[n-r],m-2,m) pow memf[n-r] memf n-r n r m-2 m 2 m n n r r m m n,k = map(int, open(0).read().split()) n map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split k dp = [0] * n dp [0] * n [0] 0 n dp[0] = 1 dp[0] dp 0 1 m = 1000000007 m 1000000007 dp[1] = (n * (n-1)) % m dp[1] dp 1 (n * (n-1)) % m n * (n-1) n n-1 n 1 m memf = [] memf [] mfappend = memf.append mfappend memf.append memf append for x in memfact(n,m):
    mfappend(x) x memfact(n,m) memfact n m mfappend(x) mfappend x for i in range(2,min(k+1,n)):
    dp[i] = (dp[i-1]+comb(n,i,m)*comb(n-1,i,m)) % m i range(2,min(k+1,n)) range 2 min(k+1,n) min k+1 k 1 n dp[i] = (dp[i-1]+comb(n,i,m)*comb(n-1,i,m)) % m dp[i] dp i (dp[i-1]+comb(n,i,m)*comb(n-1,i,m)) % m dp[i-1]+comb(n,i,m)*comb(n-1,i,m) dp[i-1] dp i-1 i 1 comb(n,i,m)*comb(n-1,i,m) comb(n,i,m) comb n i m comb(n-1,i,m) comb n-1 n 1 i m m print((dp[min(n-1,k)]+1)%m) print (dp[min(n-1,k)]+1)%m dp[min(n-1,k)]+1 dp[min(n-1,k)] dp min(n-1,k) min n-1 n 1 k 1 m memf = [] [] memf n,k = map(int, open(0).read().split()) map(int, open(0).read().split()) n def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m) def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m) comb def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp memfact dp = [0] * n [0] * n dp k = map(int, open(0).read().split()) map(int, open(0).read().split()) k mfappend = memf.append memf.append mfappend m = 1000000007 1000000007 m
def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp
def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m)

n,k = map(int, open(0).read().split())
dp = [0] * n
dp[0] = 1
m = 1000000007
dp[1] = (n * (n-1)) % m
memf = []
mfappend = memf.append
for x in memfact(n,m):
    mfappend(x)
for i in range(2,min(k+1,n)):
    dp[i] = (dp[i-1]+comb(n,i,m)*comb(n-1,i,m)) % m
print((dp[min(n-1,k)]+1)%m)