def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v


def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod


def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split()))
    c = [1, 1]  # comb(N, n), comb(N - 1, n)
    ans = 0
    for n in range(min(N - 1, K) + 1):
        ans += c[0] * c[1]
        ans %= MOD
        n_inv = mod_inv(n + 1, MOD)
        c[0] *= N - n
        c[0] *= n_inv
        c[0] %= MOD
        c[1] *= N - 1 - n
        c[1] *= n_inv
        c[1] %= MOD
    print(ans)


if __name__ == '__main__':
    main() def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v ext_euc if b == 0:
        return 1, 0, a
     b == 0 b 0 return 1, 0, a return 1, 0, a 1 0 a y, x, v = ext_euc(b, a % b) y ext_euc(b, a % b) ext_euc b a % b a b x v y -= (a // b) * x y (a // b) * x a // b a b x return x, y, v return x, y, v x y v a a b b def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod mod_inv x, _, _ = ext_euc(a, mod) x ext_euc(a, mod) ext_euc a mod _ _ return x % mod x % mod x mod a a mod mod def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split()))
    c = [1, 1]  # comb(N, n), comb(N - 1, n)
    ans = 0
    for n in range(min(N - 1, K) + 1):
        ans += c[0] * c[1]
        ans %= MOD
        n_inv = mod_inv(n + 1, MOD)
        c[0] *= N - n
        c[0] *= n_inv
        c[0] %= MOD
        c[1] *= N - 1 - n
        c[1] *= n_inv
        c[1] %= MOD
    print(ans) main MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 N, K = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K c = [1, 1] c [1, 1] 1 1 ans = 0 ans 0 for n in range(min(N - 1, K) + 1):
        ans += c[0] * c[1]
        ans %= MOD
        n_inv = mod_inv(n + 1, MOD)
        c[0] *= N - n
        c[0] *= n_inv
        c[0] %= MOD
        c[1] *= N - 1 - n
        c[1] *= n_inv
        c[1] %= MOD
     n range(min(N - 1, K) + 1) range min(N - 1, K) + 1 min(N - 1, K) min N - 1 N 1 K 1 ans += c[0] * c[1] ans c[0] * c[1] c[0] c 0 c[1] c 1 ans %= MOD ans MOD n_inv = mod_inv(n + 1, MOD) n_inv mod_inv(n + 1, MOD) mod_inv n + 1 n 1 MOD c[0] *= N - n c[0] c 0 N - n N n c[0] *= n_inv c[0] c 0 n_inv c[0] %= MOD c[0] c 0 MOD c[1] *= N - 1 - n c[1] c 1 N - 1 - n N - 1 N 1 n c[1] *= n_inv c[1] c 1 n_inv c[1] %= MOD c[1] c 1 MOD print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v ext_euc def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod mod_inv def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split()))
    c = [1, 1]  # comb(N, n), comb(N - 1, n)
    ans = 0
    for n in range(min(N - 1, K) + 1):
        ans += c[0] * c[1]
        ans %= MOD
        n_inv = mod_inv(n + 1, MOD)
        c[0] *= N - n
        c[0] *= n_inv
        c[0] %= MOD
        c[1] *= N - 1 - n
        c[1] *= n_inv
        c[1] %= MOD
    print(ans) def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split()))
    c = [1, 1]  # comb(N, n), comb(N - 1, n)
    ans = 0
    for n in range(min(N - 1, K) + 1):
        ans += c[0] * c[1]
        ans %= MOD
        n_inv = mod_inv(n + 1, MOD)
        c[0] *= N - n
        c[0] *= n_inv
        c[0] %= MOD
        c[1] *= N - 1 - n
        c[1] *= n_inv
        c[1] %= MOD
    print(ans) main
def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v


def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod


def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split()))
    c = [1, 1]  # comb(N, n), comb(N - 1, n)
    ans = 0
    for n in range(min(N - 1, K) + 1):
        ans += c[0] * c[1]
        ans %= MOD
        n_inv = mod_inv(n + 1, MOD)
        c[0] *= N - n
        c[0] *= n_inv
        c[0] %= MOD
        c[1] *= N - 1 - n
        c[1] *= n_inv
        c[1] %= MOD
    print(ans)


if __name__ == '__main__':
    main()