MOD = 10 ** 9 + 7


def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def comb(n, r, factorials, invs):
    return factorials[n] * invs[r] * invs[n - r] % MOD


def main():
    n, k = map(int, input().split())
    factorials, invs = prepare(n, MOD)
    ans = 0
    for m in range(min(k, n - 1) + 1):
        ans += comb(n - 1, m, factorials, invs) * comb(n, m, factorials, invs)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main() MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs prepare f = 1 f 1 factorials = [1] factorials [1] 1 for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
     m range(1, n + 1) range 1 n + 1 n 1 f *= m f m f %= MOD f MOD factorials.append(f) factorials.append factorials append f inv = pow(f, MOD - 2, MOD) inv pow(f, MOD - 2, MOD) pow f MOD - 2 MOD 2 MOD invs = [1] * (n + 1) invs [1] * (n + 1) [1] 1 n + 1 n 1 invs[n] = inv invs[n] invs n inv for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

     m range(n, 1, -1) range n 1 -1 inv *= m inv m inv %= MOD inv MOD invs[m - 1] = inv invs[m - 1] invs m - 1 m 1 inv return factorials, invs return factorials, invs factorials invs n n MOD MOD def comb(n, r, factorials, invs):
    return factorials[n] * invs[r] * invs[n - r] % MOD comb return factorials[n] * invs[r] * invs[n - r] % MOD factorials[n] * invs[r] * invs[n - r] % MOD factorials[n] * invs[r] * invs[n - r] factorials[n] * invs[r] factorials[n] factorials n invs[r] invs r invs[n - r] invs n - r n r MOD n n r r factorials factorials invs invs def main():
    n, k = map(int, input().split())
    factorials, invs = prepare(n, MOD)
    ans = 0
    for m in range(min(k, n - 1) + 1):
        ans += comb(n - 1, m, factorials, invs) * comb(n, m, factorials, invs)
        ans %= MOD
    print(ans) main n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k factorials, invs = prepare(n, MOD) factorials prepare(n, MOD) prepare n MOD invs ans = 0 ans 0 for m in range(min(k, n - 1) + 1):
        ans += comb(n - 1, m, factorials, invs) * comb(n, m, factorials, invs)
        ans %= MOD
     m range(min(k, n - 1) + 1) range min(k, n - 1) + 1 min(k, n - 1) min k n - 1 n 1 1 ans += comb(n - 1, m, factorials, invs) * comb(n, m, factorials, invs) ans comb(n - 1, m, factorials, invs) * comb(n, m, factorials, invs) comb(n - 1, m, factorials, invs) comb n - 1 n 1 m factorials invs comb(n, m, factorials, invs) comb n m factorials invs ans %= MOD ans MOD print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def comb(n, r, factorials, invs):
    return factorials[n] * invs[r] * invs[n - r] % MOD def comb(n, r, factorials, invs):
    return factorials[n] * invs[r] * invs[n - r] % MOD comb def main():
    n, k = map(int, input().split())
    factorials, invs = prepare(n, MOD)
    ans = 0
    for m in range(min(k, n - 1) + 1):
        ans += comb(n - 1, m, factorials, invs) * comb(n, m, factorials, invs)
        ans %= MOD
    print(ans) def main():
    n, k = map(int, input().split())
    factorials, invs = prepare(n, MOD)
    ans = 0
    for m in range(min(k, n - 1) + 1):
        ans += comb(n - 1, m, factorials, invs) * comb(n, m, factorials, invs)
        ans %= MOD
    print(ans) main def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs prepare MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
MOD = 10 ** 9 + 7


def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def comb(n, r, factorials, invs):
    return factorials[n] * invs[r] * invs[n - r] % MOD


def main():
    n, k = map(int, input().split())
    factorials, invs = prepare(n, MOD)
    ans = 0
    for m in range(min(k, n - 1) + 1):
        ans += comb(n - 1, m, factorials, invs) * comb(n, m, factorials, invs)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()
