
class Combination:
    def __init__(self, n_max, mod=10 ** 9 + 7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max + 1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod - 2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nCr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nPr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[n - r] % self.mod

    def nHr(self, n, r):
        if (n == 0 and r > 0) or r < 0:
            return 0
        return self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod


def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())

    r = min(N-1, K)
    cmb = Combination(N)

    ans = 0
    for i in range(r+1):
        ans += cmb.nCr(N, i) * cmb.nHr(N-i, i)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    resolve() class Combination:
    def __init__(self, n_max, mod=10 ** 9 + 7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max + 1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod - 2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nCr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nPr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[n - r] % self.mod

    def nHr(self, n, r):
        if (n == 0 and r > 0) or r < 0:
            return 0
        return self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod Combination def __init__(self, n_max, mod=10 ** 9 + 7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max + 1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod - 2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

     __init__ self.mod = mod self.mod self mod mod f = 1 f 1 self.fac = fac = [f] self.fac self fac [f] f = fac = [f] fac [f] for i in range(1, n_max + 1):
            f = f * i % mod
            fac.append(f)
         i range(1, n_max + 1) range 1 n_max + 1 n_max 1 f = f * i % mod f f * i % mod f * i f i mod fac.append(f) fac.append fac append f f = pow(f, mod - 2, mod) f pow(f, mod - 2, mod) pow f mod - 2 mod 2 mod self.facinv = facinv = [f] self.facinv self facinv [f] f = facinv = [f] facinv [f] for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
         i range(n_max, 0, -1) range n_max 0 -1 f = f * i % mod f f * i % mod f * i f i mod facinv.append(f) facinv.append facinv append f facinv.reverse() facinv.reverse facinv reverse self self n_max n_max mod=10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

     __call__ 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 nCr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

     nCr if not 0 <= r <= n:
            return 0
         not 0 <= r <= n 0 <= r <= n 0 <= r 0 r n return 0 0 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 nPr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[n - r] % self.mod

     nPr if not 0 <= r <= n:
            return 0
         not 0 <= r <= n 0 <= r <= n 0 <= r 0 r n return 0 0 return self.fac[n] * self.facinv[n - r] % self.mod self.fac[n] * self.facinv[n - r] % self.mod self.fac[n] * self.facinv[n - r] self.fac[n] self.fac self fac n self.facinv[n - r] self.facinv self facinv n - r n r self.mod self mod self self n n r r def nHr(self, n, r):
        if (n == 0 and r > 0) or r < 0:
            return 0
        return self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod nHr if (n == 0 and r > 0) or r < 0:
            return 0
         (n == 0 and r > 0) or r < 0 n == 0 and r > 0 n == 0 n 0 r > 0 r 0 r < 0 r 0 return 0 0 return self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] self.fac[n + r - 1] * self.facinv[r] % self.mod self.fac[n + r - 1] * self.facinv[r] self.fac[n + r - 1] self.fac self fac n + r - 1 n + r n r 1 self.facinv[r] self.facinv self facinv r self.mod self mod self.facinv[n - 1] self.facinv self facinv n - 1 n 1 self.mod self mod self self n n r r def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())

    r = min(N-1, K)
    cmb = Combination(N)

    ans = 0
    for i in range(r+1):
        ans += cmb.nCr(N, i) * cmb.nHr(N-i, i)
        ans %= MOD
    print(ans) resolve 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 r = min(N-1, K) r min(N-1, K) min N-1 N 1 K cmb = Combination(N) cmb Combination(N) Combination N ans = 0 ans 0 for i in range(r+1):
        ans += cmb.nCr(N, i) * cmb.nHr(N-i, i)
        ans %= MOD
     i range(r+1) range r+1 r 1 ans += cmb.nCr(N, i) * cmb.nHr(N-i, i) ans cmb.nCr(N, i) * cmb.nHr(N-i, i) cmb.nCr(N, i) cmb.nCr cmb nCr N i cmb.nHr(N-i, i) cmb.nHr cmb nHr N-i N i i ans %= MOD ans MOD print(ans) print ans if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())

    r = min(N-1, K)
    cmb = Combination(N)

    ans = 0
    for i in range(r+1):
        ans += cmb.nCr(N, i) * cmb.nHr(N-i, i)
        ans %= MOD
    print(ans) def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())

    r = min(N-1, K)
    cmb = Combination(N)

    ans = 0
    for i in range(r+1):
        ans += cmb.nCr(N, i) * cmb.nHr(N-i, i)
        ans %= MOD
    print(ans) resolve class Combination:
    def __init__(self, n_max, mod=10 ** 9 + 7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max + 1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod - 2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nCr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nPr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[n - r] % self.mod

    def nHr(self, n, r):
        if (n == 0 and r > 0) or r < 0:
            return 0
        return self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod class Combination:
    def __init__(self, n_max, mod=10 ** 9 + 7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max + 1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod - 2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nCr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nPr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[n - r] % self.mod

    def nHr(self, n, r):
        if (n == 0 and r > 0) or r < 0:
            return 0
        return self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod Combination

class Combination:
    def __init__(self, n_max, mod=10 ** 9 + 7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max + 1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod - 2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nCr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def nPr(self, n, r):
        if not 0 <= r <= n:
            return 0
        return self.fac[n] * self.facinv[n - r] % self.mod

    def nHr(self, n, r):
        if (n == 0 and r > 0) or r < 0:
            return 0
        return self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod


def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())

    r = min(N-1, K)
    cmb = Combination(N)

    ans = 0
    for i in range(r+1):
        ans += cmb.nCr(N, i) * cmb.nHr(N-i, i)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    resolve()
