def comb(n, k, MOD):
    if n < k:
        return 0
    if n - k < k:
        k = n - k
    comb = 1
    for x in range(n - k + 1, n + 1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k + 1):
        d = (d * x) % MOD
    comb *= pow(d, MOD - 2, MOD)
    return comb % MOD

n, k = map(int, input().split())
ans = 0
v = n
w = n - 1

ans = 1 + v * w
mod = 10 ** 9 + 7

for i in range(2, min(n,k) + 1):
    #print(f'v={v} n={n} i={i}')
    v = ((n - i + 1) * v)  * pow(i, mod - 2, mod)
    v %= mod
    w = ((n - i) * w) * pow(i, mod - 2, mod)
    w %= mod
    #print(v, w)
    ans += (v * w) % mod
    ans %= mod



print(ans) def comb(n, k, MOD):
    if n < k:
        return 0
    if n - k < k:
        k = n - k
    comb = 1
    for x in range(n - k + 1, n + 1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k + 1):
        d = (d * x) % MOD
    comb *= pow(d, MOD - 2, MOD)
    return comb % MOD comb if n < k:
        return 0
     n < k n k return 0 0 if n - k < k:
        k = n - k
     n - k < k n - k n k k k = n - k k n - k n k comb = 1 comb 1 for x in range(n - k + 1, n + 1):
        comb = (comb * x) % MOD
     x range(n - k + 1, n + 1) range n - k + 1 n - k n k 1 n + 1 n 1 comb = (comb * x) % MOD comb (comb * x) % MOD comb * x comb x MOD d = 1 d 1 for x in range(1, k + 1):
        d = (d * x) % MOD
     x range(1, k + 1) range 1 k + 1 k 1 d = (d * x) % MOD d (d * x) % MOD d * x d x MOD comb *= pow(d, MOD - 2, MOD) comb pow(d, MOD - 2, MOD) pow d MOD - 2 MOD 2 MOD return comb % MOD comb % MOD comb MOD n n k k MOD MOD n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k ans = 0 ans 0 v = n v n w = n - 1 w n - 1 n 1 ans = 1 + v * w ans 1 + v * w 1 v * w v w mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 for i in range(2, min(n,k) + 1):
    #print(f'v={v} n={n} i={i}')
    v = ((n - i + 1) * v)  * pow(i, mod - 2, mod)
    v %= mod
    w = ((n - i) * w) * pow(i, mod - 2, mod)
    w %= mod
    #print(v, w)
    ans += (v * w) % mod
    ans %= mod i range(2, min(n,k) + 1) range 2 min(n,k) + 1 min(n,k) min n k 1 v = ((n - i + 1) * v)  * pow(i, mod - 2, mod) v ((n - i + 1) * v)  * pow(i, mod - 2, mod) (n - i + 1) * v n - i + 1 n - i n i 1 v pow(i, mod - 2, mod) pow i mod - 2 mod 2 mod v %= mod v mod w = ((n - i) * w) * pow(i, mod - 2, mod) w ((n - i) * w) * pow(i, mod - 2, mod) (n - i) * w n - i n i w pow(i, mod - 2, mod) pow i mod - 2 mod 2 mod w %= mod w mod ans += (v * w) % mod ans (v * w) % mod v * w v w mod ans %= mod ans mod print(ans) print ans mod = 10 ** 9 + 7 10 ** 9 + 7 mod w = n - 1 n - 1 w def comb(n, k, MOD):
    if n < k:
        return 0
    if n - k < k:
        k = n - k
    comb = 1
    for x in range(n - k + 1, n + 1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k + 1):
        d = (d * x) % MOD
    comb *= pow(d, MOD - 2, MOD)
    return comb % MOD def comb(n, k, MOD):
    if n < k:
        return 0
    if n - k < k:
        k = n - k
    comb = 1
    for x in range(n - k + 1, n + 1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k + 1):
        d = (d * x) % MOD
    comb *= pow(d, MOD - 2, MOD)
    return comb % MOD comb ans += (v * w) % mod (v * w) % mod ans n, k = map(int, input().split()) map(int, input().split()) n ans = 0 0 ans ans %= mod mod ans v = ((n - i + 1) * v)  * pow(i, mod - 2, mod) ((n - i + 1) * v)  * pow(i, mod - 2, mod) v v = n n v ans = 1 + v * w 1 + v * w ans w = ((n - i) * w) * pow(i, mod - 2, mod) ((n - i) * w) * pow(i, mod - 2, mod) w k = map(int, input().split()) map(int, input().split()) k v %= mod mod v w %= mod mod w
def comb(n, k, MOD):
    if n < k:
        return 0
    if n - k < k:
        k = n - k
    comb = 1
    for x in range(n - k + 1, n + 1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k + 1):
        d = (d * x) % MOD
    comb *= pow(d, MOD - 2, MOD)
    return comb % MOD

n, k = map(int, input().split())
ans = 0
v = n
w = n - 1

ans = 1 + v * w
mod = 10 ** 9 + 7

for i in range(2, min(n,k) + 1):
    #print(f'v={v} n={n} i={i}')
    v = ((n - i + 1) * v)  * pow(i, mod - 2, mod)
    v %= mod
    w = ((n - i) * w) * pow(i, mod - 2, mod)
    w %= mod
    #print(v, w)
    ans += (v * w) % mod
    ans %= mod



print(ans)