import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
n,k = map(int,input().split())
MOD = 10**9 + 7
def comb(n, k, mod):
    if n<0 or k<0 or n<k:
        return 0
    if n==0 or k==0:
        return 1
    k=k if k<=n-k else n-k
    x = 1
    y = 1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return (x*pow(y,mod-2,mod))%mod
#こっちは計算量O(N)
fac = [1, 1]
inv = [0, 1]
finv = [1, 1]
for i in range(2, 2*n+1):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD) 
def comb_mod(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m
if k >= n-1:
    ans = comb_mod(2*n-1,n,MOD)
    print(ans%MOD)
elif k == 1:
    print(n*(n-1)%MOD)
else:
    ans = 0
    for i in range(k+1):
        ans += comb_mod(n-1,i,MOD)*comb_mod(n,i,MOD)
    print(ans%MOD) import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 from collections import defaultdict from collections import Counter import fractions fractions import math math from collections import deque from bisect import bisect_left from bisect import insort_left import itertools itertools from heapq import heapify from heapq import heappop from heapq import heappush import heapq heapq import numpy as np numpy INF = float("inf") INF float("inf") float "inf" 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 def comb(n, k, mod):
    if n<0 or k<0 or n<k:
        return 0
    if n==0 or k==0:
        return 1
    k=k if k<=n-k else n-k
    x = 1
    y = 1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return (x*pow(y,mod-2,mod))%mod
#こっちは計算量O(N) comb if n<0 or k<0 or n<k:
        return 0
     n<0 or k<0 or n<k n<0 or k<0 n<0 n 0 k<0 k 0 n<k n k return 0 0 if n==0 or k==0:
        return 1
     n==0 or k==0 n==0 n 0 k==0 k 0 return 1 1 k=k if k<=n-k else n-k k k if k<=n-k else n-k k<=n-k k n-k n k k n-k n k x = 1 x 1 y = 1 y 1 for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
     i range(k) range k x=x*(n-i)%mod x x*(n-i)%mod x*(n-i) x n-i n i mod y=y*(i+1)%mod y y*(i+1)%mod y*(i+1) y i+1 i 1 mod return (x*pow(y,mod-2,mod))%mod (x*pow(y,mod-2,mod))%mod x*pow(y,mod-2,mod) x pow(y,mod-2,mod) pow y mod-2 mod 2 mod mod n n k k mod mod fac = [1, 1] fac [1, 1] 1 1 inv = [0, 1] inv [0, 1] 0 1 finv = [1, 1] finv [1, 1] 1 1 for i in range(2, 2*n+1):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD)  i range(2, 2*n+1) range 2 2*n+1 2*n 2 n 1 fac.append(fac[-1] * i % MOD) fac.append fac append fac[-1] * i % MOD fac[-1] * i fac[-1] fac -1 i MOD inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD) inv.append inv append 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 finv.append(finv[-1] * inv[-1] % MOD) finv.append finv append finv[-1] * inv[-1] % MOD finv[-1] * inv[-1] finv[-1] finv -1 inv[-1] inv -1 MOD def comb_mod(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m comb_mod if (n<0 or r<0 or n<r): return 0
     n<0 or r<0 or n<r n<0 or r<0 n<0 n 0 r<0 r 0 n<r n r r = min(r, n-r) r min(r, n-r) min r n-r n r return fac[n] * finv[n-r] * finv[r] % m fac[n] * finv[n-r] * finv[r] % m fac[n] * finv[n-r] * finv[r] fac[n] * finv[n-r] fac[n] fac n finv[n-r] finv n-r n r finv[r] finv r m n n r r m m if k >= n-1:
    ans = comb_mod(2*n-1,n,MOD)
    print(ans%MOD)
elif k == 1:
    print(n*(n-1)%MOD)
else:
    ans = 0
    for i in range(k+1):
        ans += comb_mod(n-1,i,MOD)*comb_mod(n,i,MOD)
    print(ans%MOD) k >= n-1 k n-1 n 1 ans = comb_mod(2*n-1,n,MOD) ans comb_mod(2*n-1,n,MOD) comb_mod 2*n-1 2*n 2 n 1 n MOD print(ans%MOD) print ans%MOD ans MOD elif k == 1:
    print(n*(n-1)%MOD) k == 1 k 1 print(n*(n-1)%MOD) print n*(n-1)%MOD n*(n-1) n n-1 n 1 MOD ans = 0 ans 0 for i in range(k+1):
        ans += comb_mod(n-1,i,MOD)*comb_mod(n,i,MOD)
     i range(k+1) range k+1 k 1 ans += comb_mod(n-1,i,MOD)*comb_mod(n,i,MOD) ans comb_mod(n-1,i,MOD)*comb_mod(n,i,MOD) comb_mod(n-1,i,MOD) comb_mod n-1 n 1 i MOD comb_mod(n,i,MOD) comb_mod n i MOD print(ans%MOD) print ans%MOD ans MOD ans += comb_mod(n-1,i,MOD)*comb_mod(n,i,MOD) comb_mod(n-1,i,MOD)*comb_mod(n,i,MOD) ans ans = comb_mod(2*n-1,n,MOD) comb_mod(2*n-1,n,MOD) ans INF = float("inf") float("inf") INF n,k = map(int,input().split()) map(int,input().split()) n def comb(n, k, mod):
    if n<0 or k<0 or n<k:
        return 0
    if n==0 or k==0:
        return 1
    k=k if k<=n-k else n-k
    x = 1
    y = 1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return (x*pow(y,mod-2,mod))%mod
#こっちは計算量O(N) def comb(n, k, mod):
    if n<0 or k<0 or n<k:
        return 0
    if n==0 or k==0:
        return 1
    k=k if k<=n-k else n-k
    x = 1
    y = 1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return (x*pow(y,mod-2,mod))%mod
#こっちは計算量O(N) comb fac = [1, 1] [1, 1] fac ans = 0 0 ans finv = [1, 1] [1, 1] finv inv = [0, 1] [0, 1] inv input=sys.stdin.readline sys.stdin.readline input k = map(int,input().split()) map(int,input().split()) k def comb_mod(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m def comb_mod(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m comb_mod MOD = 10**9 + 7 10**9 + 7 MOD
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
n,k = map(int,input().split())
MOD = 10**9 + 7
def comb(n, k, mod):
    if n<0 or k<0 or n<k:
        return 0
    if n==0 or k==0:
        return 1
    k=k if k<=n-k else n-k
    x = 1
    y = 1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return (x*pow(y,mod-2,mod))%mod
#こっちは計算量O(N)
fac = [1, 1]
inv = [0, 1]
finv = [1, 1]
for i in range(2, 2*n+1):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD) 
def comb_mod(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m
if k >= n-1:
    ans = comb_mod(2*n-1,n,MOD)
    print(ans%MOD)
elif k == 1:
    print(n*(n-1)%MOD)
else:
    ans = 0
    for i in range(k+1):
        ans += comb_mod(n-1,i,MOD)*comb_mod(n,i,MOD)
    print(ans%MOD)