"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
class ModInt {
    constructor(value, mod) {
        this.value = value;
        this.mod = mod;
        this.value %= mod;
        if (this.value < 0)
            this.value += mod;
    }
    add(value) {
        if (typeof value === "number") {
            return new ModInt(this.value + (value % this.mod), this.mod);
        }
        else {
            if (value.mod !== this.mod)
                throw new Error("the mods are not same");
            return new ModInt(this.value + value.value, this.mod);
        }
    }
    sub(value) {
        if (typeof value === "number") {
            return this.add(-value);
        }
        else {
            if (value.mod !== this.mod)
                throw new Error("the mods are not same");
            return this.add(new ModInt(-value.value, this.mod));
        }
    }
    mul(value) {
        if (typeof value === "number") {
            return new ModInt(ModInt.multiplyMod(this.value, value, this.mod), this.mod);
        }
        else {
            if (value.mod !== this.mod)
                throw new Error("the mods are not same");
            return this.mul(value.value);
        }
    }
    div(value) {
        if (typeof value === "number") {
            return new ModInt(value, this.mod).inverse().mul(this.value);
        }
        else {
            if (value.mod !== this.mod)
                throw new Error("the mods are not same");
            return value.inverse().mul(this);
        }
    }
    inverse() {
        if (ModInt.gcd(this.value, this.mod) !== 1)
            throw new Error(`${this.value} is not coprime to ${this.mod}`);
        return new ModInt(ModInt.gcdEx(this.value, this.mod)[0], this.mod);
    }
    pow(n) {
        const rem = (x, y) => x === Infinity ? Infinity : x % y;
        const powMod = (x, n) => {
            if (n <= 0)
                return 1;
            if (n % 2 === 0)
                return powMod(rem(ModInt.multiplyMod(x, x, this.mod), this.mod), n / 2);
            else
                return rem(ModInt.multiplyMod(x, powMod(x, n - 1), this.mod), this.mod);
        };
        return new ModInt(powMod(this.value, n), this.mod);
    }
    static combination(n, k, mod) {
        if (typeof n === "number" && typeof k === "number" && typeof mod === "number") {
            n = new ModInt(n, mod);
            k = new ModInt(k, mod);
        }
        if (typeof n === "number" || typeof k === "number")
            throw new Error("argument type mismatched");
        if (n.mod !== k.mod)
            throw new Error("the mods are not same");
        const m = n.mod;
        const modint = (x) => new ModInt(x, m);
        if (n.value <= 0 || k.value <= 0)
            return modint(1);
        if (this.factorial_cache[m] === undefined)
            this.factorial_cache[m] = [modint(1)];
        if (this.factorial_cache[m].length <= n.value) {
            for (let i = this.factorial_cache[m].length; i <= n.value; i++) {
                this.factorial_cache[m][i] = this.factorial_cache[m][i - 1].mul(i);
            }
        }
        let result = modint(1);
        result = result.mul(this.factorial_cache[m][n.value]);
        result = result.div(this.factorial_cache[m][k.value]);
        result = result.div(this.factorial_cache[m][n.value - k.value]);
        return result;
    }
    /**
     * avoid overflow and calc x*y%mod
     * @param x non-negative int
     * @param y non-negative int
     * @param mod
     */
    static multiplyMod(x, y, mod) {
        if (x * y < Number.MAX_SAFE_INTEGER)
            return x * y % mod;
        // avoid overflow
        const multiplymod = (x, y) => {
            if (y <= 0)
                return 0;
            if (y % 2 === 0)
                return ModInt.multiplyMod(x, y / 2, mod) * 2 % mod;
            else
                return ModInt.multiplyMod(x, y - 1, mod) + x % mod;
        };
        return multiplymod(x, y);
    }
    ;
    /**
     * get a maximum number z s.t. x%z==0 && x%y==0
     */
    static gcd(x, y) {
        if (y === 0)
            return x;
        return ModInt.gcd(y, x % y);
    }
    /**
     * get one (a,b) pair that satisfies ax+by=gcd(a,b)
     * @returns [a, b]
     */
    static gcdEx(x, y) {
        let a0 = 1;
        let a1 = 0;
        let b0 = 0;
        let b1 = 1;
        while (y > 0) {
            const r = Math.floor(x / y);
            const _xy = [y, x % y];
            x = _xy[0]; y = _xy[1];
            const _a = [a1, a0 - r * a1];
            a0 = _a[0], a1 = _a[1];
            const _b = [b1, b0 - r * b1];
            b0 = _b[0], b1 = _b[1];
        }
        return [a0, b0];
    }
}
ModInt.factorial_cache = [];
const MOD = Math.pow(10, 9) + 7;
const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");
const n = input[0].split(" ").map((x) => +x)[0];
const k = input[0].split(" ").map((x) => +x)[1];
let result = new ModInt(0, MOD);
for (let i = 0; i <= Math.min(n - 1, k); i++) {
    result = result.add(ModInt.combination(n, i, MOD).mul(ModInt.combination(n - 1, i, MOD)));
}
console.log(result.value);
