#!/usr/bin/env python3
import sys
INF = 1<<32
MOD = 1000000007  # type: int

# def iterate_tokens():
#     for line in sys.stdin:
#         for word in line.split():
#             yield word
# tokens = iterate_tokens()
# n = int(next(tokens))  # type: int
# k = int(next(tokens))  # type: int


def solve(n: int, k: int):
    fact = [1] * (n+1)
    ifact = [1] * (n+1)
    for i in range(1, n+1):
        fact[i] = i*fact[i-1] % MOD

    ifact[-1] = pow(fact[-1], MOD-2, MOD)
    for i in range(n-1, 0, -1):
        ifact[i] = ifact[i+1] * (i+1) % MOD

    def comb(n, r, MOD=10**9+7):
        return fact[n] * ifact[n-r] * ifact[r] % MOD
    
    
    ans = 0
    for i in range(min(k, n-1)+1):
        ans += comb(n, i) * comb(n-1, i) % MOD
        ans %= MOD
    
    print(ans)

    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(n, k)

if __name__ == '__main__':
    main() import sys sys INF = 1<<32 INF 1<<32 1 32 MOD = 1000000007 MOD 1000000007 def solve(n: int, k: int):
    fact = [1] * (n+1)
    ifact = [1] * (n+1)
    for i in range(1, n+1):
        fact[i] = i*fact[i-1] % MOD

    ifact[-1] = pow(fact[-1], MOD-2, MOD)
    for i in range(n-1, 0, -1):
        ifact[i] = ifact[i+1] * (i+1) % MOD

    def comb(n, r, MOD=10**9+7):
        return fact[n] * ifact[n-r] * ifact[r] % MOD
    
    
    ans = 0
    for i in range(min(k, n-1)+1):
        ans += comb(n, i) * comb(n-1, i) % MOD
        ans %= MOD
    
    print(ans)

    return solve fact = [1] * (n+1) fact [1] * (n+1) [1] 1 n+1 n 1 ifact = [1] * (n+1) ifact [1] * (n+1) [1] 1 n+1 n 1 for i in range(1, n+1):
        fact[i] = i*fact[i-1] % MOD

     i range(1, n+1) range 1 n+1 n 1 fact[i] = i*fact[i-1] % MOD fact[i] fact i i*fact[i-1] % MOD i*fact[i-1] i fact[i-1] fact i-1 i 1 MOD ifact[-1] = pow(fact[-1], MOD-2, MOD) ifact[-1] ifact -1 pow(fact[-1], MOD-2, MOD) pow fact[-1] fact -1 MOD-2 MOD 2 MOD for i in range(n-1, 0, -1):
        ifact[i] = ifact[i+1] * (i+1) % MOD

     i range(n-1, 0, -1) range n-1 n 1 0 -1 ifact[i] = ifact[i+1] * (i+1) % MOD ifact[i] ifact i ifact[i+1] * (i+1) % MOD ifact[i+1] * (i+1) ifact[i+1] ifact i+1 i 1 i+1 i 1 MOD def comb(n, r, MOD=10**9+7):
        return fact[n] * ifact[n-r] * ifact[r] % MOD
    
    
     comb return fact[n] * ifact[n-r] * ifact[r] % MOD fact[n] * ifact[n-r] * ifact[r] % MOD fact[n] * ifact[n-r] * ifact[r] fact[n] * ifact[n-r] fact[n] fact n ifact[n-r] ifact n-r n r ifact[r] ifact r MOD n n r r MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 ans = 0 ans 0 for i in range(min(k, n-1)+1):
        ans += comb(n, i) * comb(n-1, 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 += comb(n, i) * comb(n-1, i) % MOD ans comb(n, i) * comb(n-1, i) % MOD comb(n, i) * comb(n-1, i) comb(n, i) comb n i comb(n-1, i) comb n-1 n 1 i MOD ans %= MOD ans MOD print(ans) print ans return n: int n k: int k def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(n, k) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens n = int(next(tokens)) n int(next(tokens)) int next(tokens) next tokens k = int(next(tokens)) k int(next(tokens)) int next(tokens) next tokens solve(n, k) solve n k if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def solve(n: int, k: int):
    fact = [1] * (n+1)
    ifact = [1] * (n+1)
    for i in range(1, n+1):
        fact[i] = i*fact[i-1] % MOD

    ifact[-1] = pow(fact[-1], MOD-2, MOD)
    for i in range(n-1, 0, -1):
        ifact[i] = ifact[i+1] * (i+1) % MOD

    def comb(n, r, MOD=10**9+7):
        return fact[n] * ifact[n-r] * ifact[r] % MOD
    
    
    ans = 0
    for i in range(min(k, n-1)+1):
        ans += comb(n, i) * comb(n-1, i) % MOD
        ans %= MOD
    
    print(ans)

    return def solve(n: int, k: int):
    fact = [1] * (n+1)
    ifact = [1] * (n+1)
    for i in range(1, n+1):
        fact[i] = i*fact[i-1] % MOD

    ifact[-1] = pow(fact[-1], MOD-2, MOD)
    for i in range(n-1, 0, -1):
        ifact[i] = ifact[i+1] * (i+1) % MOD

    def comb(n, r, MOD=10**9+7):
        return fact[n] * ifact[n-r] * ifact[r] % MOD
    
    
    ans = 0
    for i in range(min(k, n-1)+1):
        ans += comb(n, i) * comb(n-1, i) % MOD
        ans %= MOD
    
    print(ans)

    return solve INF = 1<<32 1<<32 INF MOD = 1000000007 1000000007 MOD def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(n, k) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(n, k) main
#!/usr/bin/env python3
import sys
INF = 1<<32
MOD = 1000000007  # type: int

# def iterate_tokens():
#     for line in sys.stdin:
#         for word in line.split():
#             yield word
# tokens = iterate_tokens()
# n = int(next(tokens))  # type: int
# k = int(next(tokens))  # type: int


def solve(n: int, k: int):
    fact = [1] * (n+1)
    ifact = [1] * (n+1)
    for i in range(1, n+1):
        fact[i] = i*fact[i-1] % MOD

    ifact[-1] = pow(fact[-1], MOD-2, MOD)
    for i in range(n-1, 0, -1):
        ifact[i] = ifact[i+1] * (i+1) % MOD

    def comb(n, r, MOD=10**9+7):
        return fact[n] * ifact[n-r] * ifact[r] % MOD
    
    
    ans = 0
    for i in range(min(k, n-1)+1):
        ans += comb(n, i) * comb(n-1, i) % MOD
        ans %= MOD
    
    print(ans)

    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(n, k)

if __name__ == '__main__':
    main()