from itertools import accumulate

import numpy as np

MOD = 10 ** 9 + 7





def cumprod(A, mod=MOD):

    L = len(A)

    Lsq = int(L ** 0.5 + 1)

    A = np.resize(A, Lsq ** 2).reshape((Lsq, Lsq))

    for i in range(1, Lsq):

        A[:, i] *= A[:, i - 1]

        A[:, i] %= mod

    for i in range(1, Lsq):

        A[i] *= A[i - 1][-1]

        A[i] %= mod

    return A.ravel()[:L]





def make_fact_and_inv(U, mod=MOD):

    """

    0~Nまでのサイズ(N+1)の階乗およびその逆元の配列を返す

    """

    tmp = np.arange(U, dtype=np.int64)

    tmp[0] = 1

    fact = cumprod(tmp, mod)

    tmp = np.arange(U, 0, -1, dtype=np.int64)

    tmp[0] = pow(int(fact[-1]), mod - 2, mod)

    inv = cumprod(tmp, mod)[::-1]

    return fact, inv





fact, inv = make_fact_and_inv(2 * 10 ** 5 + 10)





def nCr(n, r, mod=MOD):

    if r < 0 or r > n or n < 0:

        return 0

    return fact[n] * inv[r] % mod * inv[n - r] % mod





if __name__ == "__main__":

    N, K = list(map(int, input().split()))



    ans = []

    for i in range(min(N - 1, K) + 1):

        val = nCr(N, i) * nCr(N - 1, i) % MOD

        ans.append(val)



    answer = 0

    while ans:

        answer = (answer + ans.pop()) % MOD

    print(answer)

U = 2 * 10 ** 5

mod = 10 ** 9 + 7





class Combination:

    """

    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う

    使い方:

    comb = Combination(SIZE, MOD)

    comb(10, 3) => 120

    """



    def __init__(self, N, MOD=10 ** 9 + 7):

        self.MOD = MOD

        self.fact, self.inv = self._make_factorial_list(N)



    def __call__(self, n, k):

        if k < 0 or k > n:

            return 0

        res = self.fact[n] * self.inv[k] % self.MOD

        res = res * self.inv[n - k] % self.MOD

        return res



    def _make_factorial_list(self, N):

        fact = [1] * (N + 1)

        inv = [1] * (N + 1)

        MOD = self.MOD

        for i in range(1, N + 1):

            fact[i] = (fact[i - 1] * i) % MOD

        inv[N] = pow(fact[N], MOD - 2, MOD)

        for i in range(N, 0, -1):

            inv[i - 1] = (inv[i] * i) % MOD

        return fact, inv





if __name__ == "__main__":

    N, K = list(map(int, input().split()))

    comb = Combination(U + 5, mod)



    ans = 1

    for i in range(1, min(K + 1, N)):

        vacant = comb(N, i)

        person = comb(N - 1, i)

        ans = (ans + vacant * person % mod) % mod

    print(ans)
from itertools import accumulate
import numpy as np

MOD = 10**9 + 7


def cumprod(A, mod=MOD):
    L = len(A)
    Lsq = int(L**0.5 + 1)
    A = np.resize(A, Lsq**2).reshape((Lsq, Lsq))
    for i in range(1, Lsq):
        A[:, i] *= A[:, i - 1]
        A[:, i] %= mod
    for i in range(1, Lsq):
        A[i] *= A[i - 1][-1]
        A[i] %= mod
    return A.ravel()[:L]


def make_fact_and_inv(U, mod=MOD):
    """
    0~Nまでのサイズ(N+1)の階乗およびその逆元の配列を返す
    """
    tmp = np.arange(U, dtype=np.int64)
    tmp[0] = 1
    fact = cumprod(tmp, mod)
    tmp = np.arange(U, 0, -1, dtype=np.int64)
    tmp[0] = pow(int(fact[-1]), mod - 2, mod)
    inv = cumprod(tmp, mod)[::-1]
    return fact, inv


fact, inv = make_fact_and_inv(2 * 10**5 + 10)


def nCr(n, r, mod=MOD):
    if r < 0 or r > n or n < 0:
        return 0
    return fact[n] * inv[r] % mod * inv[n - r] % mod


if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    ans = []
    for i in range(min(N - 1, K) + 1):
        val = nCr(N, i) * nCr(N - 1, i) % MOD
        ans.append(val)
    answer = 0
    while ans:
        answer = (answer + ans.pop()) % MOD
    print(answer)

U = 2 * 10**5
mod = 10**9 + 7


class Combination:
    """
    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10**9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    comb = Combination(U + 5, mod)
    ans = 1
    for i in range(1, min(K + 1, N)):
        vacant = comb(N, i)
        person = comb(N - 1, i)
        ans = (ans + vacant * person % mod) % mod
    print(ans)

-from itertools import accumulate -import numpy as np - -MOD = 10**9 + 7 +U = 2 * 10**5 +mod = 10**9 + 7 -def cumprod(A, mod=MOD): -    L = len(A) -    Lsq = int(L**0.5 + 1) -    A = np.resize(A, Lsq**2).reshape((Lsq, Lsq)) -    for i in range(1, Lsq): -        A[:, i] *= A[:, i - 1] -        A[:, i] %= mod -    for i in range(1, Lsq): -        A[i] *= A[i - 1][-1] -        A[i] %= mod -    return A.ravel()[:L] +class Combination: +    """ +    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う +    使い方: +    comb = Combination(SIZE, MOD) +    comb(10, 3) => 120 +    """ +    def __init__(self, N, MOD=10**9 + 7): +        self.MOD = MOD +        self.fact, self.inv = self._make_factorial_list(N) -def make_fact_and_inv(U, mod=MOD): -    """ -    0~Nまでのサイズ(N+1)の階乗およびその逆元の配列を返す -    """ -    tmp = np.arange(U, dtype=np.int64) -    tmp[0] = 1 -    fact = cumprod(tmp, mod) -    tmp = np.arange(U, 0, -1, dtype=np.int64) -    tmp[0] = pow(int(fact[-1]), mod - 2, mod) -    inv = cumprod(tmp, mod)[::-1] -    return fact, inv +    def __call__(self, n, k): +        if k < 0 or k > n: +            return 0 +        res = self.fact[n] * self.inv[k] % self.MOD +        res = res * self.inv[n - k] % self.MOD +        return res - -fact, inv = make_fact_and_inv(2 * 10**5 + 10) - - -def nCr(n, r, mod=MOD): -    if r < 0 or r > n or n < 0: -        return 0 -    return fact[n] * inv[r] % mod * inv[n - r] % mod +    def _make_factorial_list(self, N): +        fact = [1] * (N + 1) +        inv = [1] * (N + 1) +        MOD = self.MOD +        for i in range(1, N + 1): +            fact[i] = (fact[i - 1] * i) % MOD +        inv[N] = pow(fact[N], MOD - 2, MOD) +        for i in range(N, 0, -1): +            inv[i - 1] = (inv[i] * i) % MOD +        return fact, inv -    ans = [] -    for i in range(min(N - 1, K) + 1): -        val = nCr(N, i) * nCr(N - 1, i) % MOD -        ans.append(val) -    answer = 0 -    while ans: -        answer = (answer + ans.pop()) % MOD -    print(answer) +    comb = Combination(U + 5, mod) +    ans = 1 +    for i in range(1, min(K + 1, N)): +        vacant = comb(N, i) +        person = comb(N - 1, i) +        ans = (ans + vacant * person % mod) % mod +    print(ans)