def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod

n, k = map(int, input().split())
mod = 10 ** 9 + 7
fac, inv = factorial(n, mod)

if k == 1:
    print(n * (n - 1) // 2 % mod)
    quit()

if k >= n:
    k = n - 1
ans = 0
for i in range(0, k + 1):
    nci = fac[n] * inv[n-i] % mod * inv[i] % mod
    mci = fac[n-1] * inv[n-1-i] % mod * inv[i] % mod
    ans = (ans + nci * mci % mod) % mod
print(ans) def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv factorial fac = [0] * (n + 1) fac [0] * (n + 1) [0] 0 n + 1 n 1 inv = [0] * (n + 1) inv [0] * (n + 1) [0] 0 n + 1 n 1 fac[0], inv[0] = 1, 1 fac[0] fac 0 1 inv[0] inv 0 1 for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
     i range(1, n + 1) range 1 n + 1 n 1 fac[i] = fac[i-1] * i % mod fac[i] fac i fac[i-1] * i % mod fac[i-1] * i fac[i-1] fac i-1 i 1 i mod inv[i] = inverse(fac[i], mod) inv[i] inv i inverse(fac[i], mod) inverse fac[i] fac i mod return fac, inv return fac, inv fac inv n n mod mod def inverse(a, mod):
    a %= mod
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod inverse a %= mod a mod p = mod p mod x, y = 0, 1 x 0 y 1 while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
     a > 0 a 0 n = p // a n p // a p a p, a = a, p % a, p a a p % a p a x, y = y, x - n * y x y y x - n * y x n * y n y return x % mod x % mod x mod a a mod mod 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 fac, inv = factorial(n, mod) fac factorial(n, mod) factorial n mod inv if k == 1:
    print(n * (n - 1) // 2 % mod)
    quit() k == 1 k 1 print(n * (n - 1) // 2 % mod) print n * (n - 1) // 2 % mod n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 mod quit() quit if k >= n:
    k = n - 1 k >= n k n k = n - 1 k n - 1 n 1 ans = 0 ans 0 for i in range(0, k + 1):
    nci = fac[n] * inv[n-i] % mod * inv[i] % mod
    mci = fac[n-1] * inv[n-1-i] % mod * inv[i] % mod
    ans = (ans + nci * mci % mod) % mod i range(0, k + 1) range 0 k + 1 k 1 nci = fac[n] * inv[n-i] % mod * inv[i] % mod nci fac[n] * inv[n-i] % mod * inv[i] % mod fac[n] * inv[n-i] % mod * inv[i] fac[n] * inv[n-i] % mod fac[n] * inv[n-i] fac[n] fac n inv[n-i] inv n-i n i mod inv[i] inv i mod mci = fac[n-1] * inv[n-1-i] % mod * inv[i] % mod mci fac[n-1] * inv[n-1-i] % mod * inv[i] % mod fac[n-1] * inv[n-1-i] % mod * inv[i] fac[n-1] * inv[n-1-i] % mod fac[n-1] * inv[n-1-i] fac[n-1] fac n-1 n 1 inv[n-1-i] inv n-1-i n-1 n 1 i mod inv[i] inv i mod ans = (ans + nci * mci % mod) % mod ans (ans + nci * mci % mod) % mod ans + nci * mci % mod ans nci * mci % mod nci * mci nci mci mod mod print(ans) print ans mci = fac[n-1] * inv[n-1-i] % mod * inv[i] % mod fac[n-1] * inv[n-1-i] % mod * inv[i] % mod mci inv = factorial(n, mod) factorial(n, mod) inv nci = fac[n] * inv[n-i] % mod * inv[i] % mod fac[n] * inv[n-i] % mod * inv[i] % mod nci ans = (ans + nci * mci % mod) % mod (ans + nci * mci % mod) % mod ans ans = 0 0 ans k = map(int, input().split()) map(int, input().split()) k def inverse(a, mod):
    a %= mod
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod def inverse(a, mod):
    a %= mod
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod inverse n, k = map(int, input().split()) map(int, input().split()) n k = n - 1 n - 1 k fac, inv = factorial(n, mod) factorial(n, mod) fac def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv factorial mod = 10 ** 9 + 7 10 ** 9 + 7 mod
def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod

n, k = map(int, input().split())
mod = 10 ** 9 + 7
fac, inv = factorial(n, mod)

if k == 1:
    print(n * (n - 1) // 2 % mod)
    quit()

if k >= n:
    k = n - 1
ans = 0
for i in range(0, k + 1):
    nci = fac[n] * inv[n-i] % mod * inv[i] % mod
    mci = fac[n-1] * inv[n-1-i] % mod * inv[i] % mod
    ans = (ans + nci * mci % mod) % mod
print(ans)
