#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

constexpr uint_fast64_t MOD = 1e9 + 7;

template<class StoreT, class AddT, class MulT, StoreT MOD>
class ModInt
{
    using self_type = ModInt<StoreT, AddT, MulT, MOD>;
    StoreT i;

public:
    ModInt()
        : i(0)
    {}
    ModInt(StoreT i)
        : i(i)
    {}

    ModInt(const self_type& i)
        : i(i.i)
    {}

    constexpr uint_fast32_t getI() const noexcept
    {
        return i;
    }

    ModInt& operator +=(self_type rhs)
    {
        AddT i64 = static_cast<AddT>(i);
        StoreT a32 = static_cast<StoreT>((i64 + rhs.i) % MOD);
        i = a32;
        return *this;
    }

    constexpr ModInt operator +(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        newInt += rhs;
        return newInt;
    }

    ModInt& operator -=(self_type rhs)
    {
        AddT i64 = static_cast<AddT>(i);
        StoreT a32 = static_cast<StoreT>((i64 + MOD - rhs.i) % MOD);
        i = a32;
        return *this;
    }

    constexpr ModInt operator -(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        newInt -= rhs;
        return newInt;
    }

    ModInt& operator *=(self_type rhs)
    {
        MulT i64 = static_cast<MulT>(i);
        StoreT a32 = static_cast<StoreT>((i64 * rhs.i) % MOD);
        i = a32;
        return *this;
    }

    constexpr ModInt operator *(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        newInt *= rhs;
        return newInt;
    }

    constexpr ModInt operator /(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        self_type rhsInv = rhs.inv();
        newInt *= rhsInv;
        return newInt;
    }

    constexpr bool operator ==(self_type rhs) const noexcept
    {
        return i == rhs.i;
    }

    constexpr ModInt pow(int n) const noexcept
    {
        ModInt a = *this;
        ModInt res = 1;

        while (n > 0)
        {
            if (n & 1)
            {
                res *= a;
            }
            a *= a;
            n >>= 1;
        }
        return res;
    }

    constexpr self_type inv() const noexcept
    {
        return pow(MOD - 2);
    }
};

template<class StoreT, class AddT, class MulT, StoreT MOD>
std::ostream& operator <<(std::ostream& ost, ModInt<StoreT, AddT, MulT, MOD> i)
{
    ost << i.getI();
    return ost;
}

using MyModInt = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, MOD>;

MyModInt combination(MyModInt n, MyModInt r)
{
    if (r == 0 || r == n) return 1;

    MyModInt bunbo = 1, bunshi = 1;
    for (int i = n.getI(); i > (n - r).getI(); i--)
    {
        bunshi *= i;
    }
    for (int i = r.getI(); i > 0; i--)
    {
        bunbo *= i;
    }

    return bunshi / bunbo;
}

MyModInt combination(const std::vector<MyModInt> &stock, const std::vector<MyModInt>& inv, int n, int r)
{
    if (r == 0 || r == n) return 1;

    return stock[n] * inv[n-r] * inv[r];
}

void stock_kaijo(std::vector<MyModInt> &stock, std::vector<MyModInt> &inv, int n)
{
    stock.resize(n+1);
    inv.resize(n+1);
    stock[0] = 1;
    inv[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        stock[i] = stock[i - 1] * i;
        inv[i] = stock[i].inv();
    }
}

int keta_k(int n, int k)
{
	int keta = 0;
	while (n)
	{
		n /= k;
		keta++;
	}
	return keta;
}

MyModInt baai(int n, int k)
{
    std::vector<MyModInt> stock, inv;
    stock_kaijo(stock, inv, n);

    MyModInt ans;
    for (int m = 0; m <= k; m++)
    {
        ans += combination(stock, inv, n, m) * combination(stock, inv, n - 1, m);
    }
    return ans;
}

int main()
{
	int n, k;
	std::cin >> n >> k;

    std::cout << baai(n, std::min(k, n-1));
}

Measured memory_bytes: 3328