#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


template <uint_fast64_t Modulus>
struct ModInt {
    using u64 = uint_fast64_t;
    u64 val;
    constexpr ModInt(const int x = 0) noexcept : val(x >= 0 ? x%Modulus : x%(int)Modulus+Modulus){}
    constexpr const u64& value() const noexcept { return val; }
    constexpr ModInt operator-() const noexcept { return val ? Modulus-val : 0; }
    constexpr ModInt operator+(const ModInt& rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator-(const ModInt& rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator*(const ModInt& rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator/(const ModInt& rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr bool operator==(const ModInt& rhs) const noexcept { return val == rhs.val; }
    constexpr bool operator!=(const ModInt& rhs) const noexcept { return val != rhs.val; }
    constexpr ModInt& operator+=(const ModInt& rhs) noexcept {
        val += rhs.val;
        if(val >= Modulus) val -= Modulus;
        return *this;
    }
    constexpr ModInt& operator-=(const ModInt& rhs) noexcept {
        if(val < rhs.val) val += Modulus;
        val -= rhs.val;
        return *this;
    }
    constexpr ModInt& operator*=(const ModInt& rhs) noexcept {
        val = val*rhs.val%Modulus;
        return *this;
    }
    constexpr ModInt& operator/=(const ModInt& rhs) noexcept {
        *this *= rhs.inverse();
        return *this;
    }
    constexpr ModInt inverse() const noexcept {
        int a = val, b = Modulus, u = 1, v = 0;
        while(b){
            int t = a/b;
            a -= t*b; swap(a, b);
            u -= t*v; swap(u, v);
        }
        return ModInt(u);
    }
    constexpr ModInt pow(u64 n) const noexcept {
        ModInt res(1), mul(val);
        while(n > 0){
            if(n&1) res *= mul;
            mul *= mul;
            n >>= 1;
        }
        return res;
    }
    friend ostream& operator<<(ostream& os, const ModInt& rhs){ return os << rhs.val; }
    friend istream& operator>>(istream& is, ModInt& rhs){
        u64 t;
        is >> t;
        rhs = ModInt<Modulus>(t);
        return is;
    }
};
using modint = ModInt<MOD>;


template<uint_fast64_t Modulus>
struct Factorial {
    static vector<modint> fact, finv;
    static void init(int n){
        fact.resize(n+1);
        finv.resize(n+1);
        fact[0] = 1;
        repe(i, 1, n) fact[i] = modint(i)*fact[i-1];
        finv[n] = fact[n].inverse();
        repr(i, n, 0) finv[i] = modint(i+1)*finv[i+1];
    }
    static modint comb(int n, int k){
        if(n < k) return 0;
        if(n < 0 or k < 0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    static modint perm(int n, int k){
        if(n < k) return 0;
        if(n < 0 or k < 0) return 0;
        return fact[n]*finv[n-k];
    }
};
template<uint_fast64_t Modulus> vector<modint> Factorial<Modulus>::fact;
template<uint_fast64_t Modulus> vector<modint> Factorial<Modulus>::finv;
using factorial = Factorial<MOD>;


int n, k;


signed main(){
    cin >> n >> k;

    factorial::init(n);

    modint ans = 0;
    repe(i, 0, min(n-1, k)) ans += factorial::comb(n, i)*factorial::comb(n-1, n-i-1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328