#標準入力を高速に
import sys
input = sys.stdin.readline

def factorial_mod(x, y, mod):
    factorial = 1
    for i in range(x,y+1):
        factorial *= i
        factorial %= mod
    return factorial
  
def n_C_k(n, k, mod, fact):
    inv = (pow(fact[n-k], mod-2, mod) * pow(fact[k], mod-2, mod)) % mod
    return (fact[n] * inv) % mod

"""
#main関数(若干早くなる)
def main():
    mod = 10**9+7
    n, k = map(int, input().split())         
    ans = 1+n*(n-1)

    a = n
    b = n-1

    for i in range(1, min(n, k)):
        temp1 = (n-i)*pow(i+1, mod-2, mod)%mod
        a *= temp1
        a %= mod
        temp2 = (n-1-i)*pow(i+1, mod-2, mod)%mod
        b *= temp2
        b %= mod
        temp3 = a*b%mod
        ans += temp3
        ans %= mod

    print(ans)
"""


#main関数(若干早くなる)
def main():
    mod = 10**9+7
    n, k = map(int, input().split())
    ans = (1+n*(n-1))%mod

    #階乗を使いまわすver.
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i
        fact[i] %= mod

    for i in range(2, min(n-1, k)+1):
        ans += n_C_k(n, i, mod, fact)*n_C_k(n-1, i, mod, fact)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def factorial_mod(x, y, mod):
    factorial = 1
    for i in range(x,y+1):
        factorial *= i
        factorial %= mod
    return factorial
   factorial_mod factorial = 1 factorial 1 for i in range(x,y+1):
        factorial *= i
        factorial %= mod
     i range(x,y+1) range x y+1 y 1 factorial *= i factorial i factorial %= mod factorial mod return factorial factorial x x y y mod mod def n_C_k(n, k, mod, fact):
    inv = (pow(fact[n-k], mod-2, mod) * pow(fact[k], mod-2, mod)) % mod
    return (fact[n] * inv) % mod n_C_k inv = (pow(fact[n-k], mod-2, mod) * pow(fact[k], mod-2, mod)) % mod inv (pow(fact[n-k], mod-2, mod) * pow(fact[k], mod-2, mod)) % mod pow(fact[n-k], mod-2, mod) * pow(fact[k], mod-2, mod) pow(fact[n-k], mod-2, mod) pow fact[n-k] fact n-k n k mod-2 mod 2 mod pow(fact[k], mod-2, mod) pow fact[k] fact k mod-2 mod 2 mod mod return (fact[n] * inv) % mod (fact[n] * inv) % mod fact[n] * inv fact[n] fact n inv mod n n k k mod mod fact fact """
#main関数(若干早くなる)
def main():
    mod = 10**9+7
    n, k = map(int, input().split())         
    ans = 1+n*(n-1)

    a = n
    b = n-1

    for i in range(1, min(n, k)):
        temp1 = (n-i)*pow(i+1, mod-2, mod)%mod
        a *= temp1
        a %= mod
        temp2 = (n-1-i)*pow(i+1, mod-2, mod)%mod
        b *= temp2
        b %= mod
        temp3 = a*b%mod
        ans += temp3
        ans %= mod

    print(ans)
""" def main():
    mod = 10**9+7
    n, k = map(int, input().split())
    ans = (1+n*(n-1))%mod

    #階乗を使いまわすver.
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i
        fact[i] %= mod

    for i in range(2, min(n-1, k)+1):
        ans += n_C_k(n, i, mod, fact)*n_C_k(n-1, i, mod, fact)
        ans %= mod

    print(ans) main 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 ans = (1+n*(n-1))%mod ans (1+n*(n-1))%mod 1+n*(n-1) 1 n*(n-1) n n-1 n 1 mod fact = [1]*(n+1) fact [1]*(n+1) [1] 1 n+1 n 1 for i in range(1, n+1):
        fact[i] = fact[i-1]*i
        fact[i] %= mod

     i range(1, n+1) range 1 n+1 n 1 fact[i] = fact[i-1]*i fact[i] fact i fact[i-1]*i fact[i-1] fact i-1 i 1 i fact[i] %= mod fact[i] fact i mod for i in range(2, min(n-1, k)+1):
        ans += n_C_k(n, i, mod, fact)*n_C_k(n-1, i, mod, fact)
        ans %= mod

     i range(2, min(n-1, k)+1) range 2 min(n-1, k)+1 min(n-1, k) min n-1 n 1 k 1 ans += n_C_k(n, i, mod, fact)*n_C_k(n-1, i, mod, fact) ans n_C_k(n, i, mod, fact)*n_C_k(n-1, i, mod, fact) n_C_k(n, i, mod, fact) n_C_k n i mod fact n_C_k(n-1, i, mod, fact) n_C_k n-1 n 1 i mod fact ans %= mod ans mod print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def factorial_mod(x, y, mod):
    factorial = 1
    for i in range(x,y+1):
        factorial *= i
        factorial %= mod
    return factorial
   def factorial_mod(x, y, mod):
    factorial = 1
    for i in range(x,y+1):
        factorial *= i
        factorial %= mod
    return factorial
   factorial_mod def main():
    mod = 10**9+7
    n, k = map(int, input().split())
    ans = (1+n*(n-1))%mod

    #階乗を使いまわすver.
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i
        fact[i] %= mod

    for i in range(2, min(n-1, k)+1):
        ans += n_C_k(n, i, mod, fact)*n_C_k(n-1, i, mod, fact)
        ans %= mod

    print(ans) def main():
    mod = 10**9+7
    n, k = map(int, input().split())
    ans = (1+n*(n-1))%mod

    #階乗を使いまわすver.
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i
        fact[i] %= mod

    for i in range(2, min(n-1, k)+1):
        ans += n_C_k(n, i, mod, fact)*n_C_k(n-1, i, mod, fact)
        ans %= mod

    print(ans) main def n_C_k(n, k, mod, fact):
    inv = (pow(fact[n-k], mod-2, mod) * pow(fact[k], mod-2, mod)) % mod
    return (fact[n] * inv) % mod def n_C_k(n, k, mod, fact):
    inv = (pow(fact[n-k], mod-2, mod) * pow(fact[k], mod-2, mod)) % mod
    return (fact[n] * inv) % mod n_C_k input = sys.stdin.readline sys.stdin.readline input
#標準入力を高速に
import sys
input = sys.stdin.readline

def factorial_mod(x, y, mod):
    factorial = 1
    for i in range(x,y+1):
        factorial *= i
        factorial %= mod
    return factorial
  
def n_C_k(n, k, mod, fact):
    inv = (pow(fact[n-k], mod-2, mod) * pow(fact[k], mod-2, mod)) % mod
    return (fact[n] * inv) % mod

"""
#main関数(若干早くなる)
def main():
    mod = 10**9+7
    n, k = map(int, input().split())         
    ans = 1+n*(n-1)

    a = n
    b = n-1

    for i in range(1, min(n, k)):
        temp1 = (n-i)*pow(i+1, mod-2, mod)%mod
        a *= temp1
        a %= mod
        temp2 = (n-1-i)*pow(i+1, mod-2, mod)%mod
        b *= temp2
        b %= mod
        temp3 = a*b%mod
        ans += temp3
        ans %= mod

    print(ans)
"""


#main関数(若干早くなる)
def main():
    mod = 10**9+7
    n, k = map(int, input().split())
    ans = (1+n*(n-1))%mod

    #階乗を使いまわすver.
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i
        fact[i] %= mod

    for i in range(2, min(n-1, k)+1):
        ans += n_C_k(n, i, mod, fact)*n_C_k(n-1, i, mod, fact)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()
