import sys
input = lambda: sys.stdin.readline().rstrip()

mod = 10**9 + 7


class Mod:
    """
    comb = Mod(1000000)
    print(comb(5, 3))  # 5C3
    """

    def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.__make_modinv_list(n_max)
        self.fac, self.facinv = self.__make_factorial_list(n_max)

    def comb(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def factorial(self, n):
        return self.fac[n]

    def factorial_inv(self, n):
        return self.facinv[n]

    def __make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def __make_modinv_list(self, n):
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv


def solve():

    n, k = map(int, input().split())
    k = min(n - 1, k)
    m = Mod(n)

    ans = 0
    for i in range(k + 1):
        ans += m.comb(n - 1, n - 1 - i) * m.comb(n, i)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    solve() import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 class Mod:
    """
    comb = Mod(1000000)
    print(comb(5, 3))  # 5C3
    """

    def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.__make_modinv_list(n_max)
        self.fac, self.facinv = self.__make_factorial_list(n_max)

    def comb(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def factorial(self, n):
        return self.fac[n]

    def factorial_inv(self, n):
        return self.facinv[n]

    def __make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def __make_modinv_list(self, n):
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv Mod """
    comb = Mod(1000000)
    print(comb(5, 3))  # 5C3
    """ def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.__make_modinv_list(n_max)
        self.fac, self.facinv = self.__make_factorial_list(n_max)

     __init__ self.mod = mod self.mod self mod mod self.modinv = self.__make_modinv_list(n_max) self.modinv self modinv self.__make_modinv_list(n_max) self.__make_modinv_list self __make_modinv_list n_max self.fac, self.facinv = self.__make_factorial_list(n_max) self.fac self fac self.__make_factorial_list(n_max) self.__make_factorial_list self __make_factorial_list n_max self.facinv self facinv self self n_max n_max mod=10**9 + 7 mod 10**9 + 7 10**9 10 9 7 def comb(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

     comb return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] self.fac[n] * self.facinv[r] % self.mod self.fac[n] * self.facinv[r] self.fac[n] self.fac self fac n self.facinv[r] self.facinv self facinv r self.mod self mod self.facinv[n - r] self.facinv self facinv n - r n r self.mod self mod self self n n r r def factorial(self, n):
        return self.fac[n]

     factorial return self.fac[n] self.fac[n] self.fac self fac n self self n n def factorial_inv(self, n):
        return self.facinv[n]

     factorial_inv return self.facinv[n] self.facinv[n] self.facinv self facinv n self self n n def __make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

     __make_factorial_list fac = [1] fac [1] 1 facinv = [1] facinv [1] 1 for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
         i range(1, n + 1) range 1 n + 1 n 1 fac.append(fac[i - 1] * i % self.mod) fac.append fac append fac[i - 1] * i % self.mod fac[i - 1] * i fac[i - 1] fac i - 1 i 1 i self.mod self mod facinv.append(facinv[i - 1] * self.modinv[i] % self.mod) facinv.append facinv append facinv[i - 1] * self.modinv[i] % self.mod facinv[i - 1] * self.modinv[i] facinv[i - 1] facinv i - 1 i 1 self.modinv[i] self.modinv self modinv i self.mod self mod return fac, facinv return fac, facinv fac facinv self self n n def __make_modinv_list(self, n):
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv __make_modinv_list modinv = [0] * (n + 1) modinv [0] * (n + 1) [0] 0 n + 1 n 1 modinv[1] = 1 modinv[1] modinv 1 1 for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
         i range(2, n + 1) range 2 n + 1 n 1 modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod modinv[i] modinv i self.mod - self.mod // i * modinv[self.mod % i] % self.mod self.mod self mod self.mod // i * modinv[self.mod % i] % self.mod self.mod // i * modinv[self.mod % i] self.mod // i self.mod self mod i modinv[self.mod % i] modinv self.mod % i self.mod self mod i self.mod self mod return modinv modinv self self n n def solve():

    n, k = map(int, input().split())
    k = min(n - 1, k)
    m = Mod(n)

    ans = 0
    for i in range(k + 1):
        ans += m.comb(n - 1, n - 1 - i) * m.comb(n, i)
        ans %= mod

    print(ans) solve n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k k = min(n - 1, k) k min(n - 1, k) min n - 1 n 1 k m = Mod(n) m Mod(n) Mod n ans = 0 ans 0 for i in range(k + 1):
        ans += m.comb(n - 1, n - 1 - i) * m.comb(n, i)
        ans %= mod

     i range(k + 1) range k + 1 k 1 ans += m.comb(n - 1, n - 1 - i) * m.comb(n, i) ans m.comb(n - 1, n - 1 - i) * m.comb(n, i) m.comb(n - 1, n - 1 - i) m.comb m comb n - 1 n 1 n - 1 - i n - 1 n 1 i m.comb(n, i) m.comb m comb n i ans %= mod ans mod print(ans) print ans if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve class Mod:
    """
    comb = Mod(1000000)
    print(comb(5, 3))  # 5C3
    """

    def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.__make_modinv_list(n_max)
        self.fac, self.facinv = self.__make_factorial_list(n_max)

    def comb(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def factorial(self, n):
        return self.fac[n]

    def factorial_inv(self, n):
        return self.facinv[n]

    def __make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def __make_modinv_list(self, n):
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv class Mod:
    """
    comb = Mod(1000000)
    print(comb(5, 3))  # 5C3
    """

    def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.__make_modinv_list(n_max)
        self.fac, self.facinv = self.__make_factorial_list(n_max)

    def comb(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def factorial(self, n):
        return self.fac[n]

    def factorial_inv(self, n):
        return self.facinv[n]

    def __make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def __make_modinv_list(self, n):
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv Mod mod = 10**9 + 7 10**9 + 7 mod def solve():

    n, k = map(int, input().split())
    k = min(n - 1, k)
    m = Mod(n)

    ans = 0
    for i in range(k + 1):
        ans += m.comb(n - 1, n - 1 - i) * m.comb(n, i)
        ans %= mod

    print(ans) def solve():

    n, k = map(int, input().split())
    k = min(n - 1, k)
    m = Mod(n)

    ans = 0
    for i in range(k + 1):
        ans += m.comb(n - 1, n - 1 - i) * m.comb(n, i)
        ans %= mod

    print(ans) solve input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input
import sys
input = lambda: sys.stdin.readline().rstrip()

mod = 10**9 + 7


class Mod:
    """
    comb = Mod(1000000)
    print(comb(5, 3))  # 5C3
    """

    def __init__(self, n_max, mod=10**9 + 7):
        self.mod = mod
        self.modinv = self.__make_modinv_list(n_max)
        self.fac, self.facinv = self.__make_factorial_list(n_max)

    def comb(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def factorial(self, n):
        return self.fac[n]

    def factorial_inv(self, n):
        return self.facinv[n]

    def __make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def __make_modinv_list(self, n):
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod
        return modinv


def solve():

    n, k = map(int, input().split())
    k = min(n - 1, k)
    m = Mod(n)

    ans = 0
    for i in range(k + 1):
        ans += m.comb(n - 1, n - 1 - i) * m.comb(n, i)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    solve()
