def comb(p,q,A,fact = None,factinv = None): #pCq modA
  if (q < 0) or (p < q):
    return 0
  q = min(q, p - q)
  return fact[p] * factinv[q] * factinv[p-q] % A
def main():
  mod = 10 ** 9 + 7
  n, k = map(int, input().split())
  
  fact = [1] #n!をmodで割ったあまり、0! = 1
  factinv = [1,1] #(n!)^(-1)をmodで割ったあまり
  inv = [0,1] #n^-1をmodで割ったあまり
  
  for a in range(2, n + 1):
    inv.append((-inv[mod % a] * (mod // a)) % mod)
  for i in range(1, n + 1):
    fact.append((fact[-1] * i) % mod)
  for j in range(2, n + 1):
    factinv.append((factinv[-1] * inv[j]) % mod)
  ans = 0
  for i in range(min(n,k+1)): #i:空の部屋の数
    ans = (ans + comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv)) % mod
  print(ans)
main() def comb(p,q,A,fact = None,factinv = None): #pCq modA
  if (q < 0) or (p < q):
    return 0
  q = min(q, p - q)
  return fact[p] * factinv[q] * factinv[p-q] % A comb if (q < 0) or (p < q):
    return 0
   (q < 0) or (p < q) q < 0 q 0 p < q p q return 0 0 q = min(q, p - q) q min(q, p - q) min q p - q p q return fact[p] * factinv[q] * factinv[p-q] % A fact[p] * factinv[q] * factinv[p-q] % A fact[p] * factinv[q] * factinv[p-q] fact[p] * factinv[q] fact[p] fact p factinv[q] factinv q factinv[p-q] factinv p-q p q A p p q q A A fact = None fact None factinv = None factinv None def main():
  mod = 10 ** 9 + 7
  n, k = map(int, input().split())
  
  fact = [1] #n!をmodで割ったあまり、0! = 1
  factinv = [1,1] #(n!)^(-1)をmodで割ったあまり
  inv = [0,1] #n^-1をmodで割ったあまり
  
  for a in range(2, n + 1):
    inv.append((-inv[mod % a] * (mod // a)) % mod)
  for i in range(1, n + 1):
    fact.append((fact[-1] * i) % mod)
  for j in range(2, n + 1):
    factinv.append((factinv[-1] * inv[j]) % mod)
  ans = 0
  for i in range(min(n,k+1)): #i:空の部屋の数
    ans = (ans + comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv)) % 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 fact = [1] fact [1] 1 factinv = [1,1] factinv [1,1] 1 1 inv = [0,1] inv [0,1] 0 1 for a in range(2, n + 1):
    inv.append((-inv[mod % a] * (mod // a)) % mod)
   a range(2, n + 1) range 2 n + 1 n 1 inv.append((-inv[mod % a] * (mod // a)) % mod) inv.append inv append (-inv[mod % a] * (mod // a)) % mod -inv[mod % a] * (mod // a) -inv[mod % a] inv[mod % a] inv mod % a mod a mod // a mod a mod for i in range(1, n + 1):
    fact.append((fact[-1] * i) % mod)
   i range(1, n + 1) range 1 n + 1 n 1 fact.append((fact[-1] * i) % mod) fact.append fact append (fact[-1] * i) % mod fact[-1] * i fact[-1] fact -1 i mod for j in range(2, n + 1):
    factinv.append((factinv[-1] * inv[j]) % mod)
   j range(2, n + 1) range 2 n + 1 n 1 factinv.append((factinv[-1] * inv[j]) % mod) factinv.append factinv append (factinv[-1] * inv[j]) % mod factinv[-1] * inv[j] factinv[-1] factinv -1 inv[j] inv j mod ans = 0 ans 0 for i in range(min(n,k+1)): #i:空の部屋の数
    ans = (ans + comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv)) % mod
   i range(min(n,k+1)) range min(n,k+1) min n k+1 k 1 ans = (ans + comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv)) % mod ans (ans + comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv)) % mod ans + comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv) ans comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv) comb(n,i,mod,fact,factinv) comb n i mod fact factinv comb(n-1,i,mod,fact,factinv) comb n-1 n 1 i mod fact factinv mod print(ans) print ans main() main def comb(p,q,A,fact = None,factinv = None): #pCq modA
  if (q < 0) or (p < q):
    return 0
  q = min(q, p - q)
  return fact[p] * factinv[q] * factinv[p-q] % A def comb(p,q,A,fact = None,factinv = None): #pCq modA
  if (q < 0) or (p < q):
    return 0
  q = min(q, p - q)
  return fact[p] * factinv[q] * factinv[p-q] % A comb def main():
  mod = 10 ** 9 + 7
  n, k = map(int, input().split())
  
  fact = [1] #n!をmodで割ったあまり、0! = 1
  factinv = [1,1] #(n!)^(-1)をmodで割ったあまり
  inv = [0,1] #n^-1をmodで割ったあまり
  
  for a in range(2, n + 1):
    inv.append((-inv[mod % a] * (mod // a)) % mod)
  for i in range(1, n + 1):
    fact.append((fact[-1] * i) % mod)
  for j in range(2, n + 1):
    factinv.append((factinv[-1] * inv[j]) % mod)
  ans = 0
  for i in range(min(n,k+1)): #i:空の部屋の数
    ans = (ans + comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv)) % mod
  print(ans) def main():
  mod = 10 ** 9 + 7
  n, k = map(int, input().split())
  
  fact = [1] #n!をmodで割ったあまり、0! = 1
  factinv = [1,1] #(n!)^(-1)をmodで割ったあまり
  inv = [0,1] #n^-1をmodで割ったあまり
  
  for a in range(2, n + 1):
    inv.append((-inv[mod % a] * (mod // a)) % mod)
  for i in range(1, n + 1):
    fact.append((fact[-1] * i) % mod)
  for j in range(2, n + 1):
    factinv.append((factinv[-1] * inv[j]) % mod)
  ans = 0
  for i in range(min(n,k+1)): #i:空の部屋の数
    ans = (ans + comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv)) % mod
  print(ans) main
def comb(p,q,A,fact = None,factinv = None): #pCq modA
  if (q < 0) or (p < q):
    return 0
  q = min(q, p - q)
  return fact[p] * factinv[q] * factinv[p-q] % A
def main():
  mod = 10 ** 9 + 7
  n, k = map(int, input().split())
  
  fact = [1] #n!をmodで割ったあまり、0! = 1
  factinv = [1,1] #(n!)^(-1)をmodで割ったあまり
  inv = [0,1] #n^-1をmodで割ったあまり
  
  for a in range(2, n + 1):
    inv.append((-inv[mod % a] * (mod // a)) % mod)
  for i in range(1, n + 1):
    fact.append((fact[-1] * i) % mod)
  for j in range(2, n + 1):
    factinv.append((factinv[-1] * inv[j]) % mod)
  ans = 0
  for i in range(min(n,k+1)): #i:空の部屋の数
    ans = (ans + comb(n,i,mod,fact,factinv)*comb(n-1,i,mod,fact,factinv)) % mod
  print(ans)
main()