program main
  implicit none
  integer(8) :: n, k, i, m, res
  integer(8), allocatable :: fact(:), perm(:, :)
  read *, n, k
  allocate (fact(0:n), perm(n - 1:n, 0:n))
  m = 1000000007
  call calc_fact
  call calc_perm
  res = 0
  do i = 0, min(k, n - 1)
    res = res + modulo(combi(n, i, m) * combi(n - 1, i, m), m)
    res = modulo(res, m)
  end do
  print "(i0)", res
  contains

  function combi(n, k, m)
    implicit none
    integer(8), intent(in) :: n, k, m
    integer(8) :: combi, numera, denomi
    numera = perm(n, k)
    denomi = mod(fact(k), m)
    combi = mod(numera * inv(denomi, m), m)
  end function combi

  subroutine calc_perm()
    integer(8) :: i
    perm(n, 0) = 1
    do i = 1, n
      perm(n, i) = perm(n, i - 1) * (n - i + 1)
      perm(n, i) = modulo(perm(n, i), m)
    end do
    perm(n - 1, 0) = 1
    do i = 1, n - 1
      perm(n - 1, i) = perm(n - 1, i - 1) * (n - i)
      perm(n - 1, i) = modulo(perm(n - 1, i), m)
    end do
  end subroutine calc_perm

  ! O(k)
  ! function perm(n, k, m)
  !   integer(8), intent(in) :: n, k, m
  !   integer(8) :: i, perm
  !   perm = 1
  !   do i = n, n - k + 1, -1
  !     perm = mod(perm * i, m)
  !   end do
  ! end function perm

  subroutine calc_fact()
    integer(8) :: i
    fact(0) = 1
    do i = 1, n
      fact(i) = modulo(fact(i - 1) * i, m)
    end do
  end subroutine calc_fact

  ! O(n)
  ! function fact(n, m)
  !   implicit none
  !   integer(8), intent(in) :: n, m
  !   integer(8) :: i, fact
  !   fact = 1
  !   do i = 1, n
  !     fact = mod(fact * i, m)
  !   end do
  ! end function fact

  ! O(log m)
  function inv(n, m)
    implicit none
    integer(8), intent(in) :: n, m
    integer(8) :: inv
    inv = pow(n, m - 2, m)
  end function inv

  ! O(log p)
  recursive function pow(n, p, m) result(res)
    implicit none
    integer(8), intent(in) :: n, p, m
    integer(8) :: res
    if (p == 0) then
      res = 1
    else if (mod(p, 2_8) == 0) then
      res = mod(pow(n, p / 2, m) ** 2, m)
    else
      res = mod(pow(n, p - 1, m) * n, m)
    end if
  end function pow
end program main
