# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
# K回の移動が終わった後、人がいる部屋の数はNからN-K

def cmb(n, k):
    if k < 0 or k > n: return 0
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = 10 ** 6  # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)

N, K = lr()
answer = 0
for x in range(N, max(0, N-K-1), -1):
    # x個の家には1人以上いるのでこの人たちは除く
    can_move = N - x
    # x-1の壁をcan_move+1の場所に入れる
    answer += cmb(N, x) * cmb(x - 1 + can_move, can_move)
    answer %= MOD
    
print(answer % MOD)
# 31 import sys sys import numpy as np numpy sr = lambda: sys.stdin.readline().rstrip() sr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def cmb(n, k):
    if k < 0 or k > n: return 0
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD cmb if k < 0 or k > n: return 0
     k < 0 or k > n k < 0 k 0 k > n k n return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD fact[n] * fact_inv[k] % MOD * fact_inv[n-k] fact[n] * fact_inv[k] % MOD fact[n] * fact_inv[k] fact[n] fact n fact_inv[k] fact_inv k MOD fact_inv[n-k] fact_inv n-k n k MOD n n k k def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L] cumprod L = len(arr) L len(arr) len arr Lsq = int(L**.5+1) Lsq int(L**.5+1) int L**.5+1 L**.5 L .5 1 arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq) arr np.resize(arr, Lsq**2).reshape(Lsq, Lsq) np.resize(arr, Lsq**2).reshape np.resize(arr, Lsq**2) np.resize np resize arr Lsq**2 Lsq 2 reshape Lsq Lsq for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
     n range(1, Lsq) range 1 Lsq arr[:, n] *= arr[:, n-1] arr[:, n] arr : arr[:, n-1] arr : arr[:, n] %= MOD arr[:, n] arr : MOD for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
     n range(1, Lsq) range 1 Lsq arr[n] *= arr[n-1, -1] arr[n] arr n arr[n-1, -1] arr n-1 n 1 arr[n] %= MOD arr[n] arr n MOD return arr.ravel()[:L] arr.ravel()[:L] arr.ravel() arr.ravel arr ravel :L L arr arr MOD MOD def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv make_fact x = np.arange(U, dtype=np.int64) x np.arange(U, dtype=np.int64) np.arange np arange U dtype=np.int64 dtype np.int64 np int64 x[0] = 1 x[0] x 0 1 fact = cumprod(x, MOD) fact cumprod(x, MOD) cumprod x MOD x = np.arange(U, 0, -1, dtype=np.int64) x np.arange(U, 0, -1, dtype=np.int64) np.arange np arange U 0 -1 dtype=np.int64 dtype np.int64 np int64 x[0] = pow(int(fact[-1]), MOD-2, MOD) x[0] x 0 pow(int(fact[-1]), MOD-2, MOD) pow int(fact[-1]) int fact[-1] fact -1 MOD-2 MOD 2 MOD fact_inv = cumprod(x, MOD)[::-1] fact_inv cumprod(x, MOD)[::-1] (x, MOD) cumprod x MOD ::-1 -1 return fact, fact_inv return fact, fact_inv fact fact_inv U U MOD MOD U = 10 ** 6 U 10 ** 6 10 6 fact, fact_inv = make_fact(U, MOD) fact make_fact(U, MOD) make_fact U MOD fact_inv N, K = lr() N lr() lr K answer = 0 answer 0 for x in range(N, max(0, N-K-1), -1):
    # x個の家には1人以上いるのでこの人たちは除く
    can_move = N - x
    # x-1の壁をcan_move+1の場所に入れる
    answer += cmb(N, x) * cmb(x - 1 + can_move, can_move)
    answer %= MOD
     x range(N, max(0, N-K-1), -1) range N max(0, N-K-1) max 0 N-K-1 N-K N K 1 -1 can_move = N - x can_move N - x N x answer += cmb(N, x) * cmb(x - 1 + can_move, can_move) answer cmb(N, x) * cmb(x - 1 + can_move, can_move) cmb(N, x) cmb N x cmb(x - 1 + can_move, can_move) cmb x - 1 + can_move x - 1 x 1 can_move can_move answer %= MOD answer MOD print(answer % MOD) print answer % MOD answer MOD ir = lambda: int(sr()) lambda: int(sr()) ir def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv make_fact sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD fact, fact_inv = make_fact(U, MOD) make_fact(U, MOD) fact can_move = N - x N - x can_move answer += cmb(N, x) * cmb(x - 1 + can_move, can_move) cmb(N, x) * cmb(x - 1 + can_move, can_move) answer lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr answer = 0 0 answer fact_inv = make_fact(U, MOD) make_fact(U, MOD) fact_inv U = 10 ** 6 10 ** 6 U answer %= MOD MOD answer K = lr() lr() K def cmb(n, k):
    if k < 0 or k > n: return 0
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD def cmb(n, k):
    if k < 0 or k > n: return 0
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD cmb def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L] def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L] cumprod N, K = lr() lr() N
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
# K回の移動が終わった後、人がいる部屋の数はNからN-K

def cmb(n, k):
    if k < 0 or k > n: return 0
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = 10 ** 6  # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)

N, K = lr()
answer = 0
for x in range(N, max(0, N-K-1), -1):
    # x個の家には1人以上いるのでこの人たちは除く
    can_move = N - x
    # x-1の壁をcan_move+1の場所に入れる
    answer += cmb(N, x) * cmb(x - 1 + can_move, can_move)
    answer %= MOD
    
print(answer % MOD)
# 31