import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))

    comb1 = [0] * (n + 1)
    comb2 = [0] * (n + 1)

    comb1[0] = 1
    comb2[0] = 1

    for i in range(1, n + 1):
        comb1[i] = comb1[i - 1] * (n + 1 - i)
        comb2[i] = comb2[i - 1] * (n - i)
        comb1[i] %= MOD
        comb2[i] %= MOD
        inv = pow(i, MOD - 2, MOD)
        comb1[i] *= inv
        comb2[i] *= inv
        comb1[i] %= MOD
        comb2[i] %= MOD

    r = min(k, n - 1)
    ans = 0
    for i in range(r + 1):
        ans += comb1[n - i] * comb2[n - 1 - i]
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('INF') INF float('INF') float 'INF' sys.setrecursionlimit(10 ** 5) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 10 5 def main():
    n, k = list(map(int, readline().split()))

    comb1 = [0] * (n + 1)
    comb2 = [0] * (n + 1)

    comb1[0] = 1
    comb2[0] = 1

    for i in range(1, n + 1):
        comb1[i] = comb1[i - 1] * (n + 1 - i)
        comb2[i] = comb2[i - 1] * (n - i)
        comb1[i] %= MOD
        comb2[i] %= MOD
        inv = pow(i, MOD - 2, MOD)
        comb1[i] *= inv
        comb2[i] *= inv
        comb1[i] %= MOD
        comb2[i] %= MOD

    r = min(k, n - 1)
    ans = 0
    for i in range(r + 1):
        ans += comb1[n - i] * comb2[n - 1 - i]
        ans %= MOD

    print(ans) main n, k = list(map(int, readline().split())) n list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split k comb1 = [0] * (n + 1) comb1 [0] * (n + 1) [0] 0 n + 1 n 1 comb2 = [0] * (n + 1) comb2 [0] * (n + 1) [0] 0 n + 1 n 1 comb1[0] = 1 comb1[0] comb1 0 1 comb2[0] = 1 comb2[0] comb2 0 1 for i in range(1, n + 1):
        comb1[i] = comb1[i - 1] * (n + 1 - i)
        comb2[i] = comb2[i - 1] * (n - i)
        comb1[i] %= MOD
        comb2[i] %= MOD
        inv = pow(i, MOD - 2, MOD)
        comb1[i] *= inv
        comb2[i] *= inv
        comb1[i] %= MOD
        comb2[i] %= MOD

     i range(1, n + 1) range 1 n + 1 n 1 comb1[i] = comb1[i - 1] * (n + 1 - i) comb1[i] comb1 i comb1[i - 1] * (n + 1 - i) comb1[i - 1] comb1 i - 1 i 1 n + 1 - i n + 1 n 1 i comb2[i] = comb2[i - 1] * (n - i) comb2[i] comb2 i comb2[i - 1] * (n - i) comb2[i - 1] comb2 i - 1 i 1 n - i n i comb1[i] %= MOD comb1[i] comb1 i MOD comb2[i] %= MOD comb2[i] comb2 i MOD inv = pow(i, MOD - 2, MOD) inv pow(i, MOD - 2, MOD) pow i MOD - 2 MOD 2 MOD comb1[i] *= inv comb1[i] comb1 i inv comb2[i] *= inv comb2[i] comb2 i inv comb1[i] %= MOD comb1[i] comb1 i MOD comb2[i] %= MOD comb2[i] comb2 i MOD r = min(k, n - 1) r min(k, n - 1) min k n - 1 n 1 ans = 0 ans 0 for i in range(r + 1):
        ans += comb1[n - i] * comb2[n - 1 - i]
        ans %= MOD

     i range(r + 1) range r + 1 r 1 ans += comb1[n - i] * comb2[n - 1 - i] ans comb1[n - i] * comb2[n - 1 - i] comb1[n - i] comb1 n - i n i comb2[n - 1 - i] comb2 n - 1 - i n - 1 n 1 i ans %= MOD ans MOD print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n, k = list(map(int, readline().split()))

    comb1 = [0] * (n + 1)
    comb2 = [0] * (n + 1)

    comb1[0] = 1
    comb2[0] = 1

    for i in range(1, n + 1):
        comb1[i] = comb1[i - 1] * (n + 1 - i)
        comb2[i] = comb2[i - 1] * (n - i)
        comb1[i] %= MOD
        comb2[i] %= MOD
        inv = pow(i, MOD - 2, MOD)
        comb1[i] *= inv
        comb2[i] *= inv
        comb1[i] %= MOD
        comb2[i] %= MOD

    r = min(k, n - 1)
    ans = 0
    for i in range(r + 1):
        ans += comb1[n - i] * comb2[n - 1 - i]
        ans %= MOD

    print(ans) def main():
    n, k = list(map(int, readline().split()))

    comb1 = [0] * (n + 1)
    comb2 = [0] * (n + 1)

    comb1[0] = 1
    comb2[0] = 1

    for i in range(1, n + 1):
        comb1[i] = comb1[i - 1] * (n + 1 - i)
        comb2[i] = comb2[i - 1] * (n - i)
        comb1[i] %= MOD
        comb2[i] %= MOD
        inv = pow(i, MOD - 2, MOD)
        comb1[i] *= inv
        comb2[i] *= inv
        comb1[i] %= MOD
        comb2[i] %= MOD

    r = min(k, n - 1)
    ans = 0
    for i in range(r + 1):
        ans += comb1[n - i] * comb2[n - 1 - i]
        ans %= MOD

    print(ans) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD INF = float('INF') float('INF') INF readline = sys.stdin.readline sys.stdin.readline readline
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))

    comb1 = [0] * (n + 1)
    comb2 = [0] * (n + 1)

    comb1[0] = 1
    comb2[0] = 1

    for i in range(1, n + 1):
        comb1[i] = comb1[i - 1] * (n + 1 - i)
        comb2[i] = comb2[i - 1] * (n - i)
        comb1[i] %= MOD
        comb2[i] %= MOD
        inv = pow(i, MOD - 2, MOD)
        comb1[i] *= inv
        comb2[i] *= inv
        comb1[i] %= MOD
        comb2[i] %= MOD

    r = min(k, n - 1)
    ans = 0
    for i in range(r + 1):
        ans += comb1[n - i] * comb2[n - 1 - i]
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()
