import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,K = LI()
    f = [1]
    r = [1]

    s = 1
    for i in range(1,N+2):
        s = (s * i) % MOD
        f.append(s)
        r.append(pow(s,MOD-2,MOD))


    def comb(a,b):
        return f[a] * r[b] * r[a-b]

    ans = 0
    for k in range(min(K,N-1)+1):
        ans = (ans + comb(N,k) * comb(N-1,k)) % MOD
    print(ans)

if __name__ == '__main__':
    main() import sys,queue,math,copy,itertools,bisect,collections,heapq sys queue math copy itertools bisect collections heapq def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,K = LI()
    f = [1]
    r = [1]

    s = 1
    for i in range(1,N+2):
        s = (s * i) % MOD
        f.append(s)
        r.append(pow(s,MOD-2,MOD))


    def comb(a,b):
        return f[a] * r[b] * r[a-b]

    ans = 0
    for k in range(min(K,N-1)+1):
        ans = (ans + comb(N,k) * comb(N-1,k)) % MOD
    print(ans) main sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**18 INF 10**18 10 18 MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x LI = lambda : [int(x) for x in sys.stdin.readline().split()] LI lambda : [int(x) for x in sys.stdin.readline().split()] [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) NI lambda : int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline N,K = LI() N LI() LI K f = [1] f [1] 1 r = [1] r [1] 1 s = 1 s 1 for i in range(1,N+2):
        s = (s * i) % MOD
        f.append(s)
        r.append(pow(s,MOD-2,MOD))


     i range(1,N+2) range 1 N+2 N 2 s = (s * i) % MOD s (s * i) % MOD s * i s i MOD f.append(s) f.append f append s r.append(pow(s,MOD-2,MOD)) r.append r append pow(s,MOD-2,MOD) pow s MOD-2 MOD 2 MOD def comb(a,b):
        return f[a] * r[b] * r[a-b]

     comb return f[a] * r[b] * r[a-b] f[a] * r[b] * r[a-b] f[a] * r[b] f[a] f a r[b] r b r[a-b] r a-b a b a a b b ans = 0 ans 0 for k in range(min(K,N-1)+1):
        ans = (ans + comb(N,k) * comb(N-1,k)) % MOD
     k range(min(K,N-1)+1) range min(K,N-1)+1 min(K,N-1) min K N-1 N 1 1 ans = (ans + comb(N,k) * comb(N-1,k)) % MOD ans (ans + comb(N,k) * comb(N-1,k)) % MOD ans + comb(N,k) * comb(N-1,k) ans comb(N,k) * comb(N-1,k) comb(N,k) comb N k comb(N-1,k) comb N-1 N 1 k MOD print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,K = LI()
    f = [1]
    r = [1]

    s = 1
    for i in range(1,N+2):
        s = (s * i) % MOD
        f.append(s)
        r.append(pow(s,MOD-2,MOD))


    def comb(a,b):
        return f[a] * r[b] * r[a-b]

    ans = 0
    for k in range(min(K,N-1)+1):
        ans = (ans + comb(N,k) * comb(N-1,k)) % MOD
    print(ans) def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,K = LI()
    f = [1]
    r = [1]

    s = 1
    for i in range(1,N+2):
        s = (s * i) % MOD
        f.append(s)
        r.append(pow(s,MOD-2,MOD))


    def comb(a,b):
        return f[a] * r[b] * r[a-b]

    ans = 0
    for k in range(min(K,N-1)+1):
        ans = (ans + comb(N,k) * comb(N-1,k)) % MOD
    print(ans) main
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,K = LI()
    f = [1]
    r = [1]

    s = 1
    for i in range(1,N+2):
        s = (s * i) % MOD
        f.append(s)
        r.append(pow(s,MOD-2,MOD))


    def comb(a,b):
        return f[a] * r[b] * r[a-b]

    ans = 0
    for k in range(min(K,N-1)+1):
        ans = (ans + comb(N,k) * comb(N-1,k)) % MOD
    print(ans)

if __name__ == '__main__':
    main()