class COM:
    def __init__(self, n: int, mod: int):
        self.n = n
        self.mod = mod
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]
        
        for i in range(2, n + 1):
            self.fact.append((self.fact[-1] * i) % mod)
            self.inv.append((-self.inv[mod % i] * (mod // i)) % mod)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod)
    
    def get_cmb(self, n: int, k: int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod


def solve():
    n, k = map(int, input().split())
    MOD = 10 ** 9 + 7
    
    com = COM(n, MOD)
    ans = 0
    for i in range(min(n, k + 1)):
        ans += com.get_cmb(n, i) * com.get_cmb(n - 1, i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve() class COM:
    def __init__(self, n: int, mod: int):
        self.n = n
        self.mod = mod
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]
        
        for i in range(2, n + 1):
            self.fact.append((self.fact[-1] * i) % mod)
            self.inv.append((-self.inv[mod % i] * (mod // i)) % mod)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod)
    
    def get_cmb(self, n: int, k: int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod COM def __init__(self, n: int, mod: int):
        self.n = n
        self.mod = mod
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]
        
        for i in range(2, n + 1):
            self.fact.append((self.fact[-1] * i) % mod)
            self.inv.append((-self.inv[mod % i] * (mod // i)) % mod)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod)
    
     __init__ self.n = n self.n self n n self.mod = mod self.mod self mod mod self.fact = [1, 1] self.fact self fact [1, 1] 1 1 self.factinv = [1, 1] self.factinv self factinv [1, 1] 1 1 self.inv = [0, 1] self.inv self inv [0, 1] 0 1 for i in range(2, n + 1):
            self.fact.append((self.fact[-1] * i) % mod)
            self.inv.append((-self.inv[mod % i] * (mod // i)) % mod)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod)
    
     i range(2, n + 1) range 2 n + 1 n 1 self.fact.append((self.fact[-1] * i) % mod) self.fact.append self.fact self fact append (self.fact[-1] * i) % mod self.fact[-1] * i self.fact[-1] self.fact self fact -1 i mod self.inv.append((-self.inv[mod % i] * (mod // i)) % mod) self.inv.append self.inv self inv append (-self.inv[mod % i] * (mod // i)) % mod -self.inv[mod % i] * (mod // i) -self.inv[mod % i] self.inv[mod % i] self.inv self inv mod % i mod i mod // i mod i mod self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod) self.factinv.append self.factinv self factinv append (self.factinv[-1] * self.inv[-1]) % mod self.factinv[-1] * self.inv[-1] self.factinv[-1] self.factinv self factinv -1 self.inv[-1] self.inv self inv -1 mod self self n: int n mod: int mod def get_cmb(self, n: int, k: int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod get_cmb if (k < 0) or (n < k):
            return 0
         (k < 0) or (n < k) k < 0 k 0 n < k n k return 0 0 k = min(k, n - k) k min(k, n - k) min k n - k n k return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] self.fact[n] * self.factinv[k] % self.mod self.fact[n] * self.factinv[k] self.fact[n] self.fact self fact n self.factinv[k] self.factinv self factinv k self.mod self mod self.factinv[n - k] self.factinv self factinv n - k n k self.mod self mod self self n: int n k: int k def solve():
    n, k = map(int, input().split())
    MOD = 10 ** 9 + 7
    
    com = COM(n, MOD)
    ans = 0
    for i in range(min(n, k + 1)):
        ans += com.get_cmb(n, i) * com.get_cmb(n - 1, 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 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 com = COM(n, MOD) com COM(n, MOD) COM n MOD ans = 0 ans 0 for i in range(min(n, k + 1)):
        ans += com.get_cmb(n, i) * com.get_cmb(n - 1, i)
        ans %= MOD
     i range(min(n, k + 1)) range min(n, k + 1) min n k + 1 k 1 ans += com.get_cmb(n, i) * com.get_cmb(n - 1, i) ans com.get_cmb(n, i) * com.get_cmb(n - 1, i) com.get_cmb(n, i) com.get_cmb com get_cmb n i com.get_cmb(n - 1, i) com.get_cmb com get_cmb n - 1 n 1 i ans %= MOD ans MOD print(ans) print ans if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    n, k = map(int, input().split())
    MOD = 10 ** 9 + 7
    
    com = COM(n, MOD)
    ans = 0
    for i in range(min(n, k + 1)):
        ans += com.get_cmb(n, i) * com.get_cmb(n - 1, i)
        ans %= MOD
    print(ans) def solve():
    n, k = map(int, input().split())
    MOD = 10 ** 9 + 7
    
    com = COM(n, MOD)
    ans = 0
    for i in range(min(n, k + 1)):
        ans += com.get_cmb(n, i) * com.get_cmb(n - 1, i)
        ans %= MOD
    print(ans) solve class COM:
    def __init__(self, n: int, mod: int):
        self.n = n
        self.mod = mod
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]
        
        for i in range(2, n + 1):
            self.fact.append((self.fact[-1] * i) % mod)
            self.inv.append((-self.inv[mod % i] * (mod // i)) % mod)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod)
    
    def get_cmb(self, n: int, k: int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod class COM:
    def __init__(self, n: int, mod: int):
        self.n = n
        self.mod = mod
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]
        
        for i in range(2, n + 1):
            self.fact.append((self.fact[-1] * i) % mod)
            self.inv.append((-self.inv[mod % i] * (mod // i)) % mod)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod)
    
    def get_cmb(self, n: int, k: int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod COM
class COM:
    def __init__(self, n: int, mod: int):
        self.n = n
        self.mod = mod
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]
        
        for i in range(2, n + 1):
            self.fact.append((self.fact[-1] * i) % mod)
            self.inv.append((-self.inv[mod % i] * (mod // i)) % mod)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod)
    
    def get_cmb(self, n: int, k: int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod


def solve():
    n, k = map(int, input().split())
    MOD = 10 ** 9 + 7
    
    com = COM(n, MOD)
    ans = 0
    for i in range(min(n, k + 1)):
        ans += com.get_cmb(n, i) * com.get_cmb(n - 1, i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()
