# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
def inverse(a, p):
    """逆元"""
    a_, p_ = a, p
    x, y = 1, 0
    while p_:
        t = a_ // p_
        a_ -= t * p_
        a_, p_ = p_, a_
        x -= t * y
        x, y = y, x
    x %= p
    return x


# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(n, k):
    mod = 10 ** 9 + 7
    ans = 0
    p_mod = [1, 1]
    for i in range(2, n + 1):
        p_mod.append((p_mod[-1] * i) % mod)

    for i in range(min(n, k + 1)):
        if i == 0:
            ans += 1
        elif i == 1:
            ans += n * (n - 1)
        else:
            nCi = p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) % mod
            nmHi = (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) % mod
            # ans += cmb2(n, i, mod) * cmb2(n - 1, i, mod)
            ans += nCi * nmHi % mod
        ans %= mod
    print(ans)


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    n, k = map(int, input().split())
    # Ai = [int(i) for i in input().split()]
    # Bi = [int(i) for i in input().split()]
    # ABi = [[int(i) for i in input().split()] for _ in range(N)]
    solve(n, k)

    # # test
    # from random import randint
    # from func import random_str
    # solve() def inverse(a, p):
    """逆元"""
    a_, p_ = a, p
    x, y = 1, 0
    while p_:
        t = a_ // p_
        a_ -= t * p_
        a_, p_ = p_, a_
        x -= t * y
        x, y = y, x
    x %= p
    return x


# from decorator import stop_watch
# 
# 
# @stop_watch inverse """逆元""" a_, p_ = a, p a_ a p_ p x, y = 1, 0 x 1 y 0 while p_:
        t = a_ // p_
        a_ -= t * p_
        a_, p_ = p_, a_
        x -= t * y
        x, y = y, x
     p_ t = a_ // p_ t a_ // p_ a_ p_ a_ -= t * p_ a_ t * p_ t p_ a_, p_ = p_, a_ a_ p_ p_ a_ x -= t * y x t * y t y x, y = y, x x y y x x %= p x p return x x a a p p def solve(n, k):
    mod = 10 ** 9 + 7
    ans = 0
    p_mod = [1, 1]
    for i in range(2, n + 1):
        p_mod.append((p_mod[-1] * i) % mod)

    for i in range(min(n, k + 1)):
        if i == 0:
            ans += 1
        elif i == 1:
            ans += n * (n - 1)
        else:
            nCi = p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) % mod
            nmHi = (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) % mod
            # ans += cmb2(n, i, mod) * cmb2(n - 1, i, mod)
            ans += nCi * nmHi % mod
        ans %= mod
    print(ans) solve mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 ans = 0 ans 0 p_mod = [1, 1] p_mod [1, 1] 1 1 for i in range(2, n + 1):
        p_mod.append((p_mod[-1] * i) % mod)

     i range(2, n + 1) range 2 n + 1 n 1 p_mod.append((p_mod[-1] * i) % mod) p_mod.append p_mod append (p_mod[-1] * i) % mod p_mod[-1] * i p_mod[-1] p_mod -1 i mod for i in range(min(n, k + 1)):
        if i == 0:
            ans += 1
        elif i == 1:
            ans += n * (n - 1)
        else:
            nCi = p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) % mod
            nmHi = (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) % mod
            # ans += cmb2(n, i, mod) * cmb2(n - 1, i, mod)
            ans += nCi * nmHi % mod
        ans %= mod
     i range(min(n, k + 1)) range min(n, k + 1) min n k + 1 k 1 if i == 0:
            ans += 1
        elif i == 1:
            ans += n * (n - 1)
        else:
            nCi = p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) % mod
            nmHi = (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) % mod
            # ans += cmb2(n, i, mod) * cmb2(n - 1, i, mod)
            ans += nCi * nmHi % mod
         i == 0 i 0 ans += 1 ans 1 elif i == 1:
            ans += n * (n - 1)
         i == 1 i 1 ans += n * (n - 1) ans n * (n - 1) n n - 1 n 1 nCi = p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) % mod nCi p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) % mod p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) p_mod[n] * inverse(p_mod[n - i], mod) % mod p_mod[n] * inverse(p_mod[n - i], mod) p_mod[n] p_mod n inverse(p_mod[n - i], mod) inverse p_mod[n - i] p_mod n - i n i mod mod inverse(p_mod[i], mod) inverse p_mod[i] p_mod i mod mod nmHi = (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) % mod nmHi (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) % mod (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) p_mod[n - 1] p_mod n - 1 n 1 inverse(p_mod[n - i - 1], mod) inverse p_mod[n - i - 1] p_mod n - i - 1 n - i n i 1 mod mod inverse(p_mod[i], mod) inverse p_mod[i] p_mod i mod mod ans += nCi * nmHi % mod ans nCi * nmHi % mod nCi * nmHi nCi nmHi mod ans %= mod ans mod print(ans) print ans n n k k if __name__ == '__main__':
    # S = input()
    # N = int(input())
    n, k = map(int, input().split())
    # Ai = [int(i) for i in input().split()]
    # Bi = [int(i) for i in input().split()]
    # ABi = [[int(i) for i in input().split()] for _ in range(N)]
    solve(n, k)

    # # test
    # from random import randint
    # from func import random_str
    # solve() __name__ == '__main__' __name__ '__main__' n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k solve(n, k) solve n k k = map(int, input().split()) map(int, input().split()) k def inverse(a, p):
    """逆元"""
    a_, p_ = a, p
    x, y = 1, 0
    while p_:
        t = a_ // p_
        a_ -= t * p_
        a_, p_ = p_, a_
        x -= t * y
        x, y = y, x
    x %= p
    return x


# from decorator import stop_watch
# 
# 
# @stop_watch def inverse(a, p):
    """逆元"""
    a_, p_ = a, p
    x, y = 1, 0
    while p_:
        t = a_ // p_
        a_ -= t * p_
        a_, p_ = p_, a_
        x -= t * y
        x, y = y, x
    x %= p
    return x


# from decorator import stop_watch
# 
# 
# @stop_watch inverse def solve(n, k):
    mod = 10 ** 9 + 7
    ans = 0
    p_mod = [1, 1]
    for i in range(2, n + 1):
        p_mod.append((p_mod[-1] * i) % mod)

    for i in range(min(n, k + 1)):
        if i == 0:
            ans += 1
        elif i == 1:
            ans += n * (n - 1)
        else:
            nCi = p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) % mod
            nmHi = (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) % mod
            # ans += cmb2(n, i, mod) * cmb2(n - 1, i, mod)
            ans += nCi * nmHi % mod
        ans %= mod
    print(ans) def solve(n, k):
    mod = 10 ** 9 + 7
    ans = 0
    p_mod = [1, 1]
    for i in range(2, n + 1):
        p_mod.append((p_mod[-1] * i) % mod)

    for i in range(min(n, k + 1)):
        if i == 0:
            ans += 1
        elif i == 1:
            ans += n * (n - 1)
        else:
            nCi = p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) % mod
            nmHi = (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) % mod
            # ans += cmb2(n, i, mod) * cmb2(n - 1, i, mod)
            ans += nCi * nmHi % mod
        ans %= mod
    print(ans) solve n, k = map(int, input().split()) map(int, input().split()) n
# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
def inverse(a, p):
    """逆元"""
    a_, p_ = a, p
    x, y = 1, 0
    while p_:
        t = a_ // p_
        a_ -= t * p_
        a_, p_ = p_, a_
        x -= t * y
        x, y = y, x
    x %= p
    return x


# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(n, k):
    mod = 10 ** 9 + 7
    ans = 0
    p_mod = [1, 1]
    for i in range(2, n + 1):
        p_mod.append((p_mod[-1] * i) % mod)

    for i in range(min(n, k + 1)):
        if i == 0:
            ans += 1
        elif i == 1:
            ans += n * (n - 1)
        else:
            nCi = p_mod[n] * inverse(p_mod[n - i], mod) % mod * inverse(p_mod[i], mod) % mod
            nmHi = (p_mod[n - 1] * inverse(p_mod[n - i - 1], mod) % mod) * inverse(p_mod[i], mod) % mod
            # ans += cmb2(n, i, mod) * cmb2(n - 1, i, mod)
            ans += nCi * nmHi % mod
        ans %= mod
    print(ans)


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    n, k = map(int, input().split())
    # Ai = [int(i) for i in input().split()]
    # Bi = [int(i) for i in input().split()]
    # ABi = [[int(i) for i in input().split()] for _ in range(N)]
    solve(n, k)

    # # test
    # from random import randint
    # from func import random_str
    # solve()
