class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
        self.mod = mod
        self.f = f
        self.fi = fi

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

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod


max_fact = 4 * 10**5 + 100
mod = 10**9 + 7
fact_instance = Factorial(max_fact, mod)
comb_repl = fact_instance.homogeneous_product
comb = fact_instance.combination

N, K = [int(_) for _ in input().split()]
ans = 0
for r in range(min(N - 1, K) + 1):
    ans += comb(N, r) * comb_repl(N - r, r)
    ans %= mod
print(ans) class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
        self.mod = mod
        self.f = f
        self.fi = fi

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

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod Factorial def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
        self.mod = mod
        self.f = f
        self.fi = fi

     __init__ f = [1] * (max_fact + 1) f [1] * (max_fact + 1) [1] 1 max_fact + 1 max_fact 1 for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
         idx range(2, max_fact + 1) range 2 max_fact + 1 max_fact 1 f[idx] = f[idx - 1] * idx f[idx] f idx f[idx - 1] * idx f[idx - 1] f idx - 1 idx 1 idx f[idx] %= mod f[idx] f idx mod if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
         mod > max_fact mod max_fact fi = [pow(f[-1], mod - 2, mod)] fi [pow(f[-1], mod - 2, mod)] pow(f[-1], mod - 2, mod) pow f[-1] f -1 mod - 2 mod 2 mod for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
             idx range(max_fact, 0, -1) range max_fact 0 -1 fi += [fi[-1] * idx % mod] fi [fi[-1] * idx % mod] fi[-1] * idx % mod fi[-1] * idx fi[-1] fi -1 idx mod fi = fi[::-1] fi fi[::-1] fi ::-1 -1 pow(n, mod - 2, mod) for n in f for n in f n f for n in f pow(n, mod - 2, mod) pow n mod - 2 mod 2 mod fi = [pow(n, mod - 2, mod) for n in f] fi [pow(n, mod - 2, mod) for n in f] self.mod = mod self.mod self mod mod self.f = f self.f self f f self.fi = fi self.fi self fi fi self self max_fact max_fact mod mod def factorial(self, n):
        return self.f[n]

     factorial return self.f[n] self.f[n] self.f self f n self self n n def factorial_inverse(self, n):
        return self.fi[n]

     factorial_inverse return self.fi[n] self.fi[n] self.fi self fi n self self n n def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

     combination f = self.f f self.f self f fi = self.fi fi self.fi self fi return f[n] * fi[r] * fi[n - r] % self.mod f[n] * fi[r] * fi[n - r] % self.mod f[n] * fi[r] * fi[n - r] f[n] * fi[r] f[n] f n fi[r] fi r fi[n - r] fi n - r n r self.mod self mod self self n n r r def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

     permutation return self.f[n] * self.fi[n - r] % self.mod self.f[n] * self.fi[n - r] % self.mod self.f[n] * self.fi[n - r] self.f[n] self.f self f n self.fi[n - r] self.fi self fi n - r n r self.mod self mod self self n n r r def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod homogeneous_product f = self.f f self.f self f fi = self.fi fi self.fi self fi return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod f[n + r - 1] * fi[r] * fi[n - 1] % self.mod f[n + r - 1] * fi[r] * fi[n - 1] f[n + r - 1] * fi[r] f[n + r - 1] f n + r - 1 n + r n r 1 fi[r] fi r fi[n - 1] fi n - 1 n 1 self.mod self mod self self n n r r max_fact = 4 * 10**5 + 100 max_fact 4 * 10**5 + 100 4 * 10**5 4 10**5 10 5 100 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 fact_instance = Factorial(max_fact, mod) fact_instance Factorial(max_fact, mod) Factorial max_fact mod comb_repl = fact_instance.homogeneous_product comb_repl fact_instance.homogeneous_product fact_instance homogeneous_product comb = fact_instance.combination comb fact_instance.combination fact_instance combination int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ N, K = [int(_) for _ in input().split()] N [int(_) for _ in input().split()] K ans = 0 ans 0 for r in range(min(N - 1, K) + 1):
    ans += comb(N, r) * comb_repl(N - r, r)
    ans %= mod r range(min(N - 1, K) + 1) range min(N - 1, K) + 1 min(N - 1, K) min N - 1 N 1 K 1 ans += comb(N, r) * comb_repl(N - r, r) ans comb(N, r) * comb_repl(N - r, r) comb(N, r) comb N r comb_repl(N - r, r) comb_repl N - r N r r ans %= mod ans mod print(ans) print ans ans %= mod mod ans N, K = [int(_) for _ in input().split()] [int(_) for _ in input().split()] N K = [int(_) for _ in input().split()] [int(_) for _ in input().split()] K ans += comb(N, r) * comb_repl(N - r, r) comb(N, r) * comb_repl(N - r, r) ans fact_instance = Factorial(max_fact, mod) Factorial(max_fact, mod) fact_instance class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
        self.mod = mod
        self.f = f
        self.fi = fi

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

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
        self.mod = mod
        self.f = f
        self.fi = fi

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

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod Factorial max_fact = 4 * 10**5 + 100 4 * 10**5 + 100 max_fact comb_repl = fact_instance.homogeneous_product fact_instance.homogeneous_product comb_repl comb = fact_instance.combination fact_instance.combination comb ans = 0 0 ans mod = 10**9 + 7 10**9 + 7 mod
class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
        self.mod = mod
        self.f = f
        self.fi = fi

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

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod


max_fact = 4 * 10**5 + 100
mod = 10**9 + 7
fact_instance = Factorial(max_fact, mod)
comb_repl = fact_instance.homogeneous_product
comb = fact_instance.combination

N, K = [int(_) for _ in input().split()]
ans = 0
for r in range(min(N - 1, K) + 1):
    ans += comb(N, r) * comb_repl(N - r, r)
    ans %= mod
print(ans)
