class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)
    
MOD = 10**9 + 7
N, K = map(int, input().split())
com = Combinatorics(N, MOD)
ans = 0
for i in range(min(K, N-1) + 1):
    ans += (com.binom(N, i) * com.hom(N-i, i)) % MOD
    ans %= MOD
print(ans) class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)
     Combinatorics def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
     __init__ '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        ''' self.mod = mod self.mod self mod mod i: None for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) i None self.fact = {i: None for i in range(N+1)} self.fact self fact {i: None for i in range(N+1)} i: None for i in range(1, N+1) for i in range(1, N+1) i range(1, N+1) range 1 N+1 N 1 for i in range(1, N+1) i None self.inverse = {i: None for i in range(1, N+1)} self.inverse self inverse {i: None for i in range(1, N+1)} i: None for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) i None self.fact_inverse = {i: None for i in range(N+1)} self.fact_inverse self fact_inverse {i: None for i in range(N+1)} self.fact[0] = self.fact[1] = 1 self.fact[0] self.fact self fact 0 1 = self.fact[1] = 1 self.fact[1] self.fact self fact 1 1 self.fact_inverse[0] = self.fact_inverse[1] = 1 self.fact_inverse[0] self.fact_inverse self fact_inverse 0 1 = self.fact_inverse[1] = 1 self.fact_inverse[1] self.fact_inverse self fact_inverse 1 1 self.inverse[1] = 1 self.inverse[1] self.inverse self inverse 1 1 for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
     i range(2, N+1) range 2 N+1 N 1 self.fact[i] = i * self.fact[i-1] % self.mod self.fact[i] self.fact self fact i i * self.fact[i-1] % self.mod i * self.fact[i-1] i self.fact[i-1] self.fact self fact i-1 i 1 self.mod self mod q, r = divmod(self.mod, i) q divmod(self.mod, i) divmod self.mod self mod i r self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod self.inverse[i] self.inverse self inverse i (- (q % self.mod) * self.inverse[r]) % self.mod - (q % self.mod) * self.inverse[r] - (q % self.mod) q % self.mod q self.mod self mod self.inverse[r] self.inverse self inverse r self.mod self mod self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod self.fact_inverse[i] self.fact_inverse self fact_inverse i self.inverse[i] * self.fact_inverse[i-1] % self.mod self.inverse[i] * self.fact_inverse[i-1] self.inverse[i] self.inverse self inverse i self.fact_inverse[i-1] self.fact_inverse self fact_inverse i-1 i 1 self.mod self mod self self N N mod mod def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
     perm '''
        Calculate nPr = n! / (n-r)! % mod
        ''' if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
     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.fact_inverse[n-r]) % self.mod (self.fact[n] * self.fact_inverse[n-r]) % self.mod self.fact[n] * self.fact_inverse[n-r] self.fact[n] self.fact self fact n self.fact_inverse[n-r] self.fact_inverse self fact_inverse n-r n r self.mod self mod self self n n r r def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
     binom '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        ''' if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
     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.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) self.fact[n] self.fact self fact n self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod self.fact_inverse[r] * self.fact_inverse[n-r] self.fact_inverse[r] self.fact_inverse self fact_inverse r self.fact_inverse[n-r] self.fact_inverse self fact_inverse n-r n r self.mod self mod self.mod self mod self self n n r r def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)
     hom '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        ''' if n == 0 and r > 0:
            return 0
         n == 0 and r > 0 n == 0 n 0 r > 0 r 0 return 0 0 if n >= 0 and r == 0:
            return 1
         n >= 0 and r == 0 n >= 0 n 0 r == 0 r 0 return 1 1 return self.binom(n + r - 1, r) self.binom(n + r - 1, r) self.binom self binom n + r - 1 n + r n r 1 r self self n n r r 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 com = Combinatorics(N, MOD) com Combinatorics(N, MOD) Combinatorics N MOD ans = 0 ans 0 for i in range(min(K, N-1) + 1):
    ans += (com.binom(N, i) * com.hom(N-i, i)) % MOD
    ans %= MOD i range(min(K, N-1) + 1) range min(K, N-1) + 1 min(K, N-1) min K N-1 N 1 1 ans += (com.binom(N, i) * com.hom(N-i, i)) % MOD ans (com.binom(N, i) * com.hom(N-i, i)) % MOD com.binom(N, i) * com.hom(N-i, i) com.binom(N, i) com.binom com binom N i com.hom(N-i, i) com.hom com hom N-i N i i MOD ans %= MOD ans MOD print(ans) print ans K = map(int, input().split()) map(int, input().split()) K ans = 0 0 ans ans %= MOD MOD ans ans += (com.binom(N, i) * com.hom(N-i, i)) % MOD (com.binom(N, i) * com.hom(N-i, i)) % MOD ans MOD = 10**9 + 7 10**9 + 7 MOD com = Combinatorics(N, MOD) Combinatorics(N, MOD) com N, K = map(int, input().split()) map(int, input().split()) N class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)
     class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)
     Combinatorics
class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)
    
MOD = 10**9 + 7
N, K = map(int, input().split())
com = Combinatorics(N, MOD)
ans = 0
for i in range(min(K, N-1) + 1):
    ans += (com.binom(N, i) * com.hom(N-i, i)) % MOD
    ans %= MOD
print(ans)