from sys import stdin, setrecursionlimit


def initialize_cmb(m, mod=10 ** 9 + 7):
    fac = [1]
    finv = [1]
    inv = [0] * (m + 1)
    if m > 1:
        fac.append(1)
        finv.append(1)
        inv[1] = 1
        pre_fac = 1
        pre_finv = 1
        for i in range(2, m + 1):
            pre_fac = pre_fac * i % mod
            fac.append(pre_fac)
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            pre_finv = pre_finv * inv[i] % mod
            finv.append(pre_finv)
    return fac, finv


def cmb(n, k, fac, finv, mod=10 ** 9 + 7):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    input = stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = map(int, input().split())

    fac, finv = initialize_cmb(n, mod)

    c_n = []
    for i in range(n + 1):
        c_n.append(cmb(n, i, fac, finv))
    c_n_1 = []
    for i in range(n):
        c_n_1.append(cmb(n - 1, i, fac, finv))

    ans = 0
    for i in range(min(k + 1, n)):
        ans += c_n[i] * c_n_1[n - i - 1]
        ans %= mod
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main() from sys import stdin, setrecursionlimit def initialize_cmb(m, mod=10 ** 9 + 7):
    fac = [1]
    finv = [1]
    inv = [0] * (m + 1)
    if m > 1:
        fac.append(1)
        finv.append(1)
        inv[1] = 1
        pre_fac = 1
        pre_finv = 1
        for i in range(2, m + 1):
            pre_fac = pre_fac * i % mod
            fac.append(pre_fac)
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            pre_finv = pre_finv * inv[i] % mod
            finv.append(pre_finv)
    return fac, finv initialize_cmb fac = [1] fac [1] 1 finv = [1] finv [1] 1 inv = [0] * (m + 1) inv [0] * (m + 1) [0] 0 m + 1 m 1 if m > 1:
        fac.append(1)
        finv.append(1)
        inv[1] = 1
        pre_fac = 1
        pre_finv = 1
        for i in range(2, m + 1):
            pre_fac = pre_fac * i % mod
            fac.append(pre_fac)
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            pre_finv = pre_finv * inv[i] % mod
            finv.append(pre_finv)
     m > 1 m 1 fac.append(1) fac.append fac append 1 finv.append(1) finv.append finv append 1 inv[1] = 1 inv[1] inv 1 1 pre_fac = 1 pre_fac 1 pre_finv = 1 pre_finv 1 for i in range(2, m + 1):
            pre_fac = pre_fac * i % mod
            fac.append(pre_fac)
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            pre_finv = pre_finv * inv[i] % mod
            finv.append(pre_finv)
     i range(2, m + 1) range 2 m + 1 m 1 pre_fac = pre_fac * i % mod pre_fac pre_fac * i % mod pre_fac * i pre_fac i mod fac.append(pre_fac) fac.append fac append pre_fac inv[i] = mod - inv[mod % i] * (mod // i) % mod inv[i] inv i mod - inv[mod % i] * (mod // i) % mod mod inv[mod % i] * (mod // i) % mod inv[mod % i] * (mod // i) inv[mod % i] inv mod % i mod i mod // i mod i mod pre_finv = pre_finv * inv[i] % mod pre_finv pre_finv * inv[i] % mod pre_finv * inv[i] pre_finv inv[i] inv i mod finv.append(pre_finv) finv.append finv append pre_finv return fac, finv return fac, finv fac finv m m mod=10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def cmb(n, k, fac, finv, mod=10 ** 9 + 7):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod cmb if n < k:
        return 0
     n < k n k return 0 0 if n < 0 or k < 0:
        return 0
     n < 0 or k < 0 n < 0 n 0 k < 0 k 0 return 0 0 return fac[n] * (finv[k] * finv[n - k] % mod) % mod fac[n] * (finv[k] * finv[n - k] % mod) % mod fac[n] * (finv[k] * finv[n - k] % mod) fac[n] fac n finv[k] * finv[n - k] % mod finv[k] * finv[n - k] finv[k] finv k finv[n - k] finv n - k n k mod mod n n k k fac fac finv finv mod=10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def main():
    input = stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = map(int, input().split())

    fac, finv = initialize_cmb(n, mod)

    c_n = []
    for i in range(n + 1):
        c_n.append(cmb(n, i, fac, finv))
    c_n_1 = []
    for i in range(n):
        c_n_1.append(cmb(n - 1, i, fac, finv))

    ans = 0
    for i in range(min(k + 1, n)):
        ans += c_n[i] * c_n_1[n - i - 1]
        ans %= mod
    print(ans) main input = stdin.buffer.readline input stdin.buffer.readline stdin.buffer stdin buffer readline 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 fac, finv = initialize_cmb(n, mod) fac initialize_cmb(n, mod) initialize_cmb n mod finv c_n = [] c_n [] for i in range(n + 1):
        c_n.append(cmb(n, i, fac, finv))
     i range(n + 1) range n + 1 n 1 c_n.append(cmb(n, i, fac, finv)) c_n.append c_n append cmb(n, i, fac, finv) cmb n i fac finv c_n_1 = [] c_n_1 [] for i in range(n):
        c_n_1.append(cmb(n - 1, i, fac, finv))

     i range(n) range n c_n_1.append(cmb(n - 1, i, fac, finv)) c_n_1.append c_n_1 append cmb(n - 1, i, fac, finv) cmb n - 1 n 1 i fac finv ans = 0 ans 0 for i in range(min(k + 1, n)):
        ans += c_n[i] * c_n_1[n - i - 1]
        ans %= mod
     i range(min(k + 1, n)) range min(k + 1, n) min k + 1 k 1 n ans += c_n[i] * c_n_1[n - i - 1] ans c_n[i] * c_n_1[n - i - 1] c_n[i] c_n i c_n_1[n - i - 1] c_n_1 n - i - 1 n - i n i 1 ans %= mod ans mod print(ans) print ans if __name__ == "__main__":
    setrecursionlimit(10000)
    main() __name__ == "__main__" __name__ "__main__" setrecursionlimit(10000) setrecursionlimit 10000 main() main def initialize_cmb(m, mod=10 ** 9 + 7):
    fac = [1]
    finv = [1]
    inv = [0] * (m + 1)
    if m > 1:
        fac.append(1)
        finv.append(1)
        inv[1] = 1
        pre_fac = 1
        pre_finv = 1
        for i in range(2, m + 1):
            pre_fac = pre_fac * i % mod
            fac.append(pre_fac)
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            pre_finv = pre_finv * inv[i] % mod
            finv.append(pre_finv)
    return fac, finv def initialize_cmb(m, mod=10 ** 9 + 7):
    fac = [1]
    finv = [1]
    inv = [0] * (m + 1)
    if m > 1:
        fac.append(1)
        finv.append(1)
        inv[1] = 1
        pre_fac = 1
        pre_finv = 1
        for i in range(2, m + 1):
            pre_fac = pre_fac * i % mod
            fac.append(pre_fac)
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            pre_finv = pre_finv * inv[i] % mod
            finv.append(pre_finv)
    return fac, finv initialize_cmb def cmb(n, k, fac, finv, mod=10 ** 9 + 7):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod def cmb(n, k, fac, finv, mod=10 ** 9 + 7):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod cmb def main():
    input = stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = map(int, input().split())

    fac, finv = initialize_cmb(n, mod)

    c_n = []
    for i in range(n + 1):
        c_n.append(cmb(n, i, fac, finv))
    c_n_1 = []
    for i in range(n):
        c_n_1.append(cmb(n - 1, i, fac, finv))

    ans = 0
    for i in range(min(k + 1, n)):
        ans += c_n[i] * c_n_1[n - i - 1]
        ans %= mod
    print(ans) def main():
    input = stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = map(int, input().split())

    fac, finv = initialize_cmb(n, mod)

    c_n = []
    for i in range(n + 1):
        c_n.append(cmb(n, i, fac, finv))
    c_n_1 = []
    for i in range(n):
        c_n_1.append(cmb(n - 1, i, fac, finv))

    ans = 0
    for i in range(min(k + 1, n)):
        ans += c_n[i] * c_n_1[n - i - 1]
        ans %= mod
    print(ans) main
from sys import stdin, setrecursionlimit


def initialize_cmb(m, mod=10 ** 9 + 7):
    fac = [1]
    finv = [1]
    inv = [0] * (m + 1)
    if m > 1:
        fac.append(1)
        finv.append(1)
        inv[1] = 1
        pre_fac = 1
        pre_finv = 1
        for i in range(2, m + 1):
            pre_fac = pre_fac * i % mod
            fac.append(pre_fac)
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            pre_finv = pre_finv * inv[i] % mod
            finv.append(pre_finv)
    return fac, finv


def cmb(n, k, fac, finv, mod=10 ** 9 + 7):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    input = stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = map(int, input().split())

    fac, finv = initialize_cmb(n, mod)

    c_n = []
    for i in range(n + 1):
        c_n.append(cmb(n, i, fac, finv))
    c_n_1 = []
    for i in range(n):
        c_n_1.append(cmb(n - 1, i, fac, finv))

    ans = 0
    for i in range(min(k + 1, n)):
        ans += c_n[i] * c_n_1[n - i - 1]
        ans %= mod
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
