class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

N, K = map(int, input().split())
K = min(K, N)
MOD = 10**9 + 7
comb = Combination(N + 100)

ans = 0
for k in range(K + 1):
    ans += comb.ncr(N, k) * comb.nhr(N - k, k)
    ans %= MOD

print(ans) class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n] Combination def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

     __init__ self.size = size + 2 self.size self size size + 2 size 2 self.mod = mod self.mod self mod mod self.fact = [1, 1] + [0] * size self.fact self fact [1, 1] + [0] * size [1, 1] 1 1 [0] * size [0] 0 size self.factInv = [1, 1] + [0] * size self.factInv self factInv [1, 1] + [0] * size [1, 1] 1 1 [0] * size [0] 0 size self.inv = [0, 1] + [0] * size self.inv self inv [0, 1] + [0] * size [0, 1] 0 1 [0] * size [0] 0 size for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

     i range(2, self.size) range 2 self.size self size self.fact[i] = self.fact[i - 1] * i % self.mod self.fact[i] self.fact self fact i self.fact[i - 1] * i % self.mod self.fact[i - 1] * i self.fact[i - 1] self.fact self fact i - 1 i 1 i self.mod self mod self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod self.inv[i] self.inv self inv i -self.inv[self.mod % i] * (self.mod // i) % self.mod -self.inv[self.mod % i] * (self.mod // i) -self.inv[self.mod % i] self.inv[self.mod % i] self.inv self inv self.mod % i self.mod self mod i self.mod // i self.mod self mod i self.mod self mod self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod self.factInv[i] self.factInv self factInv i self.factInv[i - 1] * self.inv[i] % self.mod self.factInv[i - 1] * self.inv[i] self.factInv[i - 1] self.factInv self factInv i - 1 i 1 self.inv[i] self.inv self inv i self.mod self mod self self size size mod=10**9 + 7 mod 10**9 + 7 10**9 10 9 7 def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

     npr if n < r or n < 0 or r < 0:
            return 0
         n < r or n < 0 or r < 0 n < r or n < 0 n < r n r n < 0 n 0 r < 0 r 0 return 0 0 return self.fact[n] * self.factInv[n - r] % self.mod self.fact[n] * self.factInv[n - r] % self.mod self.fact[n] * self.factInv[n - r] self.fact[n] self.fact self fact n self.factInv[n - r] self.factInv self factInv n - r n r self.mod self mod self self n n r r def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

     ncr if n < r or n < 0 or r < 0:
            return 0
         n < r or n < 0 or r < 0 n < r or n < 0 n < r n r n < 0 n 0 r < 0 r 0 return 0 0 return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) self.fact[n] self.fact self fact n self.factInv[r] * self.factInv[n - r] % self.mod self.factInv[r] * self.factInv[n - r] self.factInv[r] self.factInv self factInv r self.factInv[n - r] self.factInv self factInv n - r n r self.mod self mod self.mod self mod self self n n r r def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

     nhr return self.ncr(n + r - 1, n - 1) self.ncr(n + r - 1, n - 1) self.ncr self ncr n + r - 1 n + r n r 1 n - 1 n 1 self self n n r r def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n] factN if n < 0:
            return 0
         n < 0 n 0 return 0 0 return self.fact[n] self.fact[n] self.fact self fact n self self n n N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K K = min(K, N) K min(K, N) min K N MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 comb = Combination(N + 100) comb Combination(N + 100) Combination N + 100 N 100 ans = 0 ans 0 for k in range(K + 1):
    ans += comb.ncr(N, k) * comb.nhr(N - k, k)
    ans %= MOD k range(K + 1) range K + 1 K 1 ans += comb.ncr(N, k) * comb.nhr(N - k, k) ans comb.ncr(N, k) * comb.nhr(N - k, k) comb.ncr(N, k) comb.ncr comb ncr N k comb.nhr(N - k, k) comb.nhr comb nhr N - k N k k ans %= MOD ans MOD print(ans) print ans N, K = map(int, input().split()) map(int, input().split()) N K = min(K, N) min(K, N) K MOD = 10**9 + 7 10**9 + 7 MOD ans %= MOD MOD ans comb = Combination(N + 100) Combination(N + 100) comb ans += comb.ncr(N, k) * comb.nhr(N - k, k) comb.ncr(N, k) * comb.nhr(N - k, k) ans class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n] class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n] Combination K = map(int, input().split()) map(int, input().split()) K ans = 0 0 ans
class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

N, K = map(int, input().split())
K = min(K, N)
MOD = 10**9 + 7
comb = Combination(N + 100)

ans = 0
for k in range(K + 1):
    ans += comb.ncr(N, k) * comb.nhr(N - k, k)
    ans %= MOD

print(ans)
