import sys
input = sys.stdin.readline


def read():
    N, K = list(map(int, input().strip().split()))
    return N, K


def binom_preprocess(n, MOD=10**9+7):
    f = [0 for i in range(n+1)]  # n!
    invf = [0 for i in range(n+1)]  # (n!)^-1
    f[0] = 1
    f[1] = 1
    invf[0] = 1
    invf[1] = 1
    for i in range(2, n+1):
        f[i] = f[i-1] * i % MOD
    invf[n] = pow(f[n], MOD-2, MOD)
    for i in range(n, 2, -1):
        invf[i-1] = invf[i] * i % MOD
    return f, invf


def binom(n, k, f, invf, MOD=10**9+7):
    if n < k or n < 0 or k < 0:
        return 0
    else:
        return (f[n] * invf[k] % MOD) * invf[n-k] % MOD


def solve(N, K, MOD=10**9+7):
    # k: 人数0の部屋の数
    # N人を(N-k)部屋に押し込む方法を考える
    f, invf = binom_preprocess(N, MOD)
    ans = 0
    for k in range(0, min(N, K+1)):
        ans += binom(N, k, f, invf, MOD) * binom(N-1, k, f, invf, MOD)
        ans %= MOD
    return ans


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs))) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def read():
    N, K = list(map(int, input().strip().split()))
    return N, K read N, K = list(map(int, input().strip().split())) N list(map(int, input().strip().split())) list map(int, input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split K return N, K return N, K N K def binom_preprocess(n, MOD=10**9+7):
    f = [0 for i in range(n+1)]  # n!
    invf = [0 for i in range(n+1)]  # (n!)^-1
    f[0] = 1
    f[1] = 1
    invf[0] = 1
    invf[1] = 1
    for i in range(2, n+1):
        f[i] = f[i-1] * i % MOD
    invf[n] = pow(f[n], MOD-2, MOD)
    for i in range(n, 2, -1):
        invf[i-1] = invf[i] * i % MOD
    return f, invf binom_preprocess 0 for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) 0 f = [0 for i in range(n+1)] f [0 for i in range(n+1)] 0 for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) 0 invf = [0 for i in range(n+1)] invf [0 for i in range(n+1)] f[0] = 1 f[0] f 0 1 f[1] = 1 f[1] f 1 1 invf[0] = 1 invf[0] invf 0 1 invf[1] = 1 invf[1] invf 1 1 for i in range(2, n+1):
        f[i] = f[i-1] * i % MOD
     i range(2, n+1) range 2 n+1 n 1 f[i] = f[i-1] * i % MOD f[i] f i f[i-1] * i % MOD f[i-1] * i f[i-1] f i-1 i 1 i MOD invf[n] = pow(f[n], MOD-2, MOD) invf[n] invf n pow(f[n], MOD-2, MOD) pow f[n] f n MOD-2 MOD 2 MOD for i in range(n, 2, -1):
        invf[i-1] = invf[i] * i % MOD
     i range(n, 2, -1) range n 2 -1 invf[i-1] = invf[i] * i % MOD invf[i-1] invf i-1 i 1 invf[i] * i % MOD invf[i] * i invf[i] invf i i MOD return f, invf return f, invf f invf n n MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 def binom(n, k, f, invf, MOD=10**9+7):
    if n < k or n < 0 or k < 0:
        return 0
    else:
        return (f[n] * invf[k] % MOD) * invf[n-k] % MOD binom if n < k or n < 0 or k < 0:
        return 0
    else:
        return (f[n] * invf[k] % MOD) * invf[n-k] % MOD n < k or n < 0 or k < 0 n < k or n < 0 n < k n k n < 0 n 0 k < 0 k 0 return 0 0 return (f[n] * invf[k] % MOD) * invf[n-k] % MOD (f[n] * invf[k] % MOD) * invf[n-k] % MOD (f[n] * invf[k] % MOD) * invf[n-k] f[n] * invf[k] % MOD f[n] * invf[k] f[n] f n invf[k] invf k MOD invf[n-k] invf n-k n k MOD n n k k f f invf invf MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 def solve(N, K, MOD=10**9+7):
    # k: 人数0の部屋の数
    # N人を(N-k)部屋に押し込む方法を考える
    f, invf = binom_preprocess(N, MOD)
    ans = 0
    for k in range(0, min(N, K+1)):
        ans += binom(N, k, f, invf, MOD) * binom(N-1, k, f, invf, MOD)
        ans %= MOD
    return ans solve f, invf = binom_preprocess(N, MOD) f binom_preprocess(N, MOD) binom_preprocess N MOD invf ans = 0 ans 0 for k in range(0, min(N, K+1)):
        ans += binom(N, k, f, invf, MOD) * binom(N-1, k, f, invf, MOD)
        ans %= MOD
     k range(0, min(N, K+1)) range 0 min(N, K+1) min N K+1 K 1 ans += binom(N, k, f, invf, MOD) * binom(N-1, k, f, invf, MOD) ans binom(N, k, f, invf, MOD) * binom(N-1, k, f, invf, MOD) binom(N, k, f, invf, MOD) binom N k f invf MOD binom(N-1, k, f, invf, MOD) binom N-1 N 1 k f invf MOD ans %= MOD ans MOD return ans ans N N K K MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs))) __name__ == '__main__' __name__ '__main__' inputs = read() inputs read() read print("{}".format(solve(*inputs))) print "{}".format(solve(*inputs)) "{}".format "{}" format solve(*inputs) solve *inputs inputs def read():
    N, K = list(map(int, input().strip().split()))
    return N, K def read():
    N, K = list(map(int, input().strip().split()))
    return N, K read def binom(n, k, f, invf, MOD=10**9+7):
    if n < k or n < 0 or k < 0:
        return 0
    else:
        return (f[n] * invf[k] % MOD) * invf[n-k] % MOD def binom(n, k, f, invf, MOD=10**9+7):
    if n < k or n < 0 or k < 0:
        return 0
    else:
        return (f[n] * invf[k] % MOD) * invf[n-k] % MOD binom def solve(N, K, MOD=10**9+7):
    # k: 人数0の部屋の数
    # N人を(N-k)部屋に押し込む方法を考える
    f, invf = binom_preprocess(N, MOD)
    ans = 0
    for k in range(0, min(N, K+1)):
        ans += binom(N, k, f, invf, MOD) * binom(N-1, k, f, invf, MOD)
        ans %= MOD
    return ans def solve(N, K, MOD=10**9+7):
    # k: 人数0の部屋の数
    # N人を(N-k)部屋に押し込む方法を考える
    f, invf = binom_preprocess(N, MOD)
    ans = 0
    for k in range(0, min(N, K+1)):
        ans += binom(N, k, f, invf, MOD) * binom(N-1, k, f, invf, MOD)
        ans %= MOD
    return ans solve input = sys.stdin.readline sys.stdin.readline input def binom_preprocess(n, MOD=10**9+7):
    f = [0 for i in range(n+1)]  # n!
    invf = [0 for i in range(n+1)]  # (n!)^-1
    f[0] = 1
    f[1] = 1
    invf[0] = 1
    invf[1] = 1
    for i in range(2, n+1):
        f[i] = f[i-1] * i % MOD
    invf[n] = pow(f[n], MOD-2, MOD)
    for i in range(n, 2, -1):
        invf[i-1] = invf[i] * i % MOD
    return f, invf def binom_preprocess(n, MOD=10**9+7):
    f = [0 for i in range(n+1)]  # n!
    invf = [0 for i in range(n+1)]  # (n!)^-1
    f[0] = 1
    f[1] = 1
    invf[0] = 1
    invf[1] = 1
    for i in range(2, n+1):
        f[i] = f[i-1] * i % MOD
    invf[n] = pow(f[n], MOD-2, MOD)
    for i in range(n, 2, -1):
        invf[i-1] = invf[i] * i % MOD
    return f, invf binom_preprocess inputs = read() read() inputs
import sys
input = sys.stdin.readline


def read():
    N, K = list(map(int, input().strip().split()))
    return N, K


def binom_preprocess(n, MOD=10**9+7):
    f = [0 for i in range(n+1)]  # n!
    invf = [0 for i in range(n+1)]  # (n!)^-1
    f[0] = 1
    f[1] = 1
    invf[0] = 1
    invf[1] = 1
    for i in range(2, n+1):
        f[i] = f[i-1] * i % MOD
    invf[n] = pow(f[n], MOD-2, MOD)
    for i in range(n, 2, -1):
        invf[i-1] = invf[i] * i % MOD
    return f, invf


def binom(n, k, f, invf, MOD=10**9+7):
    if n < k or n < 0 or k < 0:
        return 0
    else:
        return (f[n] * invf[k] % MOD) * invf[n-k] % MOD


def solve(N, K, MOD=10**9+7):
    # k: 人数0の部屋の数
    # N人を(N-k)部屋に押し込む方法を考える
    f, invf = binom_preprocess(N, MOD)
    ans = 0
    for k in range(0, min(N, K+1)):
        ans += binom(N, k, f, invf, MOD) * binom(N-1, k, f, invf, MOD)
        ans %= MOD
    return ans


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))
