class Facts:

  def __init__(self, mod=10**9+7, n_max=1):
    self.mod     = mod
    self.n_max   = n_max
    self.fact    = [1, 1]
    self.inv     = [0, 1]
    self.factinv = [1, 1]
    if 1 < n_max:
      self.setup_table(n_max)

  def cmb(self, n, r):
    if r < 0 or n < r:
      return 0
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod

  def factorial(self, n):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n]
    
  def hom(self, n, k):
    return self.cmb(n+k-1, k)

  def prm(self, n, k):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * self.factinv[n-k] % self.mod

  def setup_table(self, t):
    for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
    self.n_max = t

# ABC156 Roaming
mod = 10 ** 9 + 7

n, k = map(int, input().split())

ans = 0
f = Facts(mod)

for i in range(0, min(n-1, k)+1):
  ans += f.cmb(n,i) * f.hom(n-i,i) % mod
  if ans >= mod:
    ans -= mod 

print(ans)

# ABC167 E 2020/5/11
# mod = 998244353

# n, m, k = map(int, input().split())

# ans = 0
# f = Facts(mod)
# t = m * pow(m-1, n-1-k, mod)

# for i in range(k,-1,-1):
#   ans += f.cmb(n-1,i) * t % mod
#   t = t * (m-1) % mod

# print(ans % mod) class Facts:

  def __init__(self, mod=10**9+7, n_max=1):
    self.mod     = mod
    self.n_max   = n_max
    self.fact    = [1, 1]
    self.inv     = [0, 1]
    self.factinv = [1, 1]
    if 1 < n_max:
      self.setup_table(n_max)

  def cmb(self, n, r):
    if r < 0 or n < r:
      return 0
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod

  def factorial(self, n):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n]
    
  def hom(self, n, k):
    return self.cmb(n+k-1, k)

  def prm(self, n, k):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * self.factinv[n-k] % self.mod

  def setup_table(self, t):
    for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
    self.n_max = t

# ABC156 Roaming Facts def __init__(self, mod=10**9+7, n_max=1):
    self.mod     = mod
    self.n_max   = n_max
    self.fact    = [1, 1]
    self.inv     = [0, 1]
    self.factinv = [1, 1]
    if 1 < n_max:
      self.setup_table(n_max)

   __init__ self.mod     = mod self.mod self mod mod self.n_max   = n_max self.n_max self n_max n_max self.fact    = [1, 1] self.fact self fact [1, 1] 1 1 self.inv     = [0, 1] self.inv self inv [0, 1] 0 1 self.factinv = [1, 1] self.factinv self factinv [1, 1] 1 1 if 1 < n_max:
      self.setup_table(n_max)

   1 < n_max 1 n_max self.setup_table(n_max) self.setup_table self setup_table n_max self self mod=10**9+7 mod 10**9+7 10**9 10 9 7 n_max=1 n_max 1 def cmb(self, n, r):
    if r < 0 or n < r:
      return 0
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod

   cmb if r < 0 or n < r:
      return 0
     r < 0 or n < r r < 0 r 0 n < r n r return 0 0 if self.n_max < n:
      self.setup_table(n)
     self.n_max < n self.n_max self n_max n self.setup_table(n) self.setup_table self setup_table n return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) self.fact[n] self.fact self fact n self.factinv[r] * self.factinv[n-r] % self.mod self.factinv[r] * self.factinv[n-r] self.factinv[r] self.factinv self factinv r self.factinv[n-r] self.factinv self factinv n-r n r self.mod self mod self.mod self mod self self n n r r def factorial(self, n):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n]
    
   factorial if self.n_max < n:
      self.setup_table(n)
     self.n_max < n self.n_max self n_max n self.setup_table(n) self.setup_table self setup_table n return self.fact[n] self.fact[n] self.fact self fact n self self n n def hom(self, n, k):
    return self.cmb(n+k-1, k)

   hom return self.cmb(n+k-1, k) self.cmb(n+k-1, k) self.cmb self cmb n+k-1 n+k n k 1 k self self n n k k def prm(self, n, k):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * self.factinv[n-k] % self.mod

   prm if self.n_max < n:
      self.setup_table(n)
     self.n_max < n self.n_max self n_max n self.setup_table(n) self.setup_table self setup_table n return self.fact[n] * self.factinv[n-k] % self.mod self.fact[n] * self.factinv[n-k] % self.mod self.fact[n] * self.factinv[n-k] self.fact[n] self.fact self fact n self.factinv[n-k] self.factinv self factinv n-k n k self.mod self mod self self n n k k def setup_table(self, t):
    for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
    self.n_max = t

# ABC156 Roaming setup_table for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
     i range(self.n_max+1,t+1) range self.n_max+1 self.n_max self n_max 1 t+1 t 1 self.fact.append( self.fact[-1] * i % self.mod ) self.fact.append self.fact self fact append self.fact[-1] * i % self.mod self.fact[-1] * i self.fact[-1] self.fact self fact -1 i self.mod self mod self.inv.append( -self.inv[mod % i] * (self.mod // i) % self.mod ) self.inv.append self.inv self inv append -self.inv[mod % i] * (self.mod // i) % self.mod -self.inv[mod % i] * (self.mod // i) -self.inv[mod % i] self.inv[mod % i] self.inv self inv mod % i mod i self.mod // i self.mod self mod i self.mod self mod self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod ) self.factinv.append self.factinv self factinv append self.factinv[-1] * self.inv[-1] % self.mod self.factinv[-1] * self.inv[-1] self.factinv[-1] self.factinv self factinv -1 self.inv[-1] self.inv self inv -1 self.mod self mod self.n_max = t self.n_max self n_max t self self t t 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 = 0 ans 0 f = Facts(mod) f Facts(mod) Facts mod for i in range(0, min(n-1, k)+1):
  ans += f.cmb(n,i) * f.hom(n-i,i) % mod
  if ans >= mod:
    ans -= mod  i range(0, min(n-1, k)+1) range 0 min(n-1, k)+1 min(n-1, k) min n-1 n 1 k 1 ans += f.cmb(n,i) * f.hom(n-i,i) % mod ans f.cmb(n,i) * f.hom(n-i,i) % mod f.cmb(n,i) * f.hom(n-i,i) f.cmb(n,i) f.cmb f cmb n i f.hom(n-i,i) f.hom f hom n-i n i i mod if ans >= mod:
    ans -= mod  ans >= mod ans mod ans -= mod ans mod print(ans) print ans f = Facts(mod) Facts(mod) f ans += f.cmb(n,i) * f.hom(n-i,i) % mod f.cmb(n,i) * f.hom(n-i,i) % mod ans class Facts:

  def __init__(self, mod=10**9+7, n_max=1):
    self.mod     = mod
    self.n_max   = n_max
    self.fact    = [1, 1]
    self.inv     = [0, 1]
    self.factinv = [1, 1]
    if 1 < n_max:
      self.setup_table(n_max)

  def cmb(self, n, r):
    if r < 0 or n < r:
      return 0
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod

  def factorial(self, n):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n]
    
  def hom(self, n, k):
    return self.cmb(n+k-1, k)

  def prm(self, n, k):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * self.factinv[n-k] % self.mod

  def setup_table(self, t):
    for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
    self.n_max = t

# ABC156 Roaming class Facts:

  def __init__(self, mod=10**9+7, n_max=1):
    self.mod     = mod
    self.n_max   = n_max
    self.fact    = [1, 1]
    self.inv     = [0, 1]
    self.factinv = [1, 1]
    if 1 < n_max:
      self.setup_table(n_max)

  def cmb(self, n, r):
    if r < 0 or n < r:
      return 0
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod

  def factorial(self, n):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n]
    
  def hom(self, n, k):
    return self.cmb(n+k-1, k)

  def prm(self, n, k):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * self.factinv[n-k] % self.mod

  def setup_table(self, t):
    for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
    self.n_max = t

# ABC156 Roaming Facts ans -= mod mod ans k = map(int, input().split()) map(int, input().split()) k n, k = map(int, input().split()) map(int, input().split()) n ans = 0 0 ans mod = 10 ** 9 + 7 10 ** 9 + 7 mod
class Facts:

  def __init__(self, mod=10**9+7, n_max=1):
    self.mod     = mod
    self.n_max   = n_max
    self.fact    = [1, 1]
    self.inv     = [0, 1]
    self.factinv = [1, 1]
    if 1 < n_max:
      self.setup_table(n_max)

  def cmb(self, n, r):
    if r < 0 or n < r:
      return 0
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod

  def factorial(self, n):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n]
    
  def hom(self, n, k):
    return self.cmb(n+k-1, k)

  def prm(self, n, k):
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * self.factinv[n-k] % self.mod

  def setup_table(self, t):
    for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
    self.n_max = t

# ABC156 Roaming
mod = 10 ** 9 + 7

n, k = map(int, input().split())

ans = 0
f = Facts(mod)

for i in range(0, min(n-1, k)+1):
  ans += f.cmb(n,i) * f.hom(n-i,i) % mod
  if ans >= mod:
    ans -= mod 

print(ans)

# ABC167 E 2020/5/11
# mod = 998244353

# n, m, k = map(int, input().split())

# ans = 0
# f = Facts(mod)
# t = m * pow(m-1, n-1-k, mod)

# for i in range(k,-1,-1):
#   ans += f.cmb(n-1,i) * t % mod
#   t = t * (m-1) % mod

# print(ans % mod)
