def main():
    N, k = map(int, input().split())

    MAX_N = 3 * 10 ** 5
    MOD = 10 ** 9 + 7
    fac = [0]*MAX_N
    inv = [0]*MAX_N
    finv = [0]*MAX_N
    fac[0] = 1; fac[1] = 1
    inv[1] = 1
    finv[0] = 1; finv[1] = 1

    def com_init():
        for i in range(2, MAX_N):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = -(MOD//i)*inv[MOD%i]%MOD
            finv[i] = finv[i-1]*inv[i]%MOD

    def com(n, k):
        if n < 0:return 0
        elif k > n: return 0
        
        return (fac[n]*finv[n-k]%MOD)*finv[k]%MOD
    
    k = min(k, N-1)
    ans = 1
    com_init()
    for i in range(1, k+1):
        ans += com(N, i)*com(N-1, N-i-1)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main() def main():
    N, k = map(int, input().split())

    MAX_N = 3 * 10 ** 5
    MOD = 10 ** 9 + 7
    fac = [0]*MAX_N
    inv = [0]*MAX_N
    finv = [0]*MAX_N
    fac[0] = 1; fac[1] = 1
    inv[1] = 1
    finv[0] = 1; finv[1] = 1

    def com_init():
        for i in range(2, MAX_N):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = -(MOD//i)*inv[MOD%i]%MOD
            finv[i] = finv[i-1]*inv[i]%MOD

    def com(n, k):
        if n < 0:return 0
        elif k > n: return 0
        
        return (fac[n]*finv[n-k]%MOD)*finv[k]%MOD
    
    k = min(k, N-1)
    ans = 1
    com_init()
    for i in range(1, k+1):
        ans += com(N, i)*com(N-1, N-i-1)
        ans %= MOD
    print(ans) main N, k = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split k MAX_N = 3 * 10 ** 5 MAX_N 3 * 10 ** 5 3 10 ** 5 10 5 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 fac = [0]*MAX_N fac [0]*MAX_N [0] 0 MAX_N inv = [0]*MAX_N inv [0]*MAX_N [0] 0 MAX_N finv = [0]*MAX_N finv [0]*MAX_N [0] 0 MAX_N fac[0] = 1 fac[0] fac 0 1 fac[1] = 1 fac[1] fac 1 1 inv[1] = 1 inv[1] inv 1 1 finv[0] = 1 finv[0] finv 0 1 finv[1] = 1 finv[1] finv 1 1 def com_init():
        for i in range(2, MAX_N):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = -(MOD//i)*inv[MOD%i]%MOD
            finv[i] = finv[i-1]*inv[i]%MOD

     com_init for i in range(2, MAX_N):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = -(MOD//i)*inv[MOD%i]%MOD
            finv[i] = finv[i-1]*inv[i]%MOD

     i range(2, MAX_N) range 2 MAX_N fac[i] = fac[i-1] * i % MOD fac[i] fac i fac[i-1] * i % MOD fac[i-1] * i fac[i-1] fac i-1 i 1 i MOD inv[i] = -(MOD//i)*inv[MOD%i]%MOD inv[i] inv i -(MOD//i)*inv[MOD%i]%MOD -(MOD//i)*inv[MOD%i] -(MOD//i) MOD//i MOD i inv[MOD%i] inv MOD%i MOD i MOD finv[i] = finv[i-1]*inv[i]%MOD finv[i] finv i finv[i-1]*inv[i]%MOD finv[i-1]*inv[i] finv[i-1] finv i-1 i 1 inv[i] inv i MOD def com(n, k):
        if n < 0:return 0
        elif k > n: return 0
        
        return (fac[n]*finv[n-k]%MOD)*finv[k]%MOD
    
     com if n < 0:return 0
        elif k > n: return 0
        
         n < 0 n 0 elif k > n: return 0
        
         k > n k n return (fac[n]*finv[n-k]%MOD)*finv[k]%MOD (fac[n]*finv[n-k]%MOD)*finv[k]%MOD (fac[n]*finv[n-k]%MOD)*finv[k] fac[n]*finv[n-k]%MOD fac[n]*finv[n-k] fac[n] fac n finv[n-k] finv n-k n k MOD finv[k] finv k MOD n n k k k = min(k, N-1) k min(k, N-1) min k N-1 N 1 ans = 1 ans 1 com_init() com_init for i in range(1, k+1):
        ans += com(N, i)*com(N-1, N-i-1)
        ans %= MOD
     i range(1, k+1) range 1 k+1 k 1 ans += com(N, i)*com(N-1, N-i-1) ans com(N, i)*com(N-1, N-i-1) com(N, i) com N i com(N-1, N-i-1) com N-1 N 1 N-i-1 N-i N i 1 ans %= MOD ans MOD print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, k = map(int, input().split())

    MAX_N = 3 * 10 ** 5
    MOD = 10 ** 9 + 7
    fac = [0]*MAX_N
    inv = [0]*MAX_N
    finv = [0]*MAX_N
    fac[0] = 1; fac[1] = 1
    inv[1] = 1
    finv[0] = 1; finv[1] = 1

    def com_init():
        for i in range(2, MAX_N):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = -(MOD//i)*inv[MOD%i]%MOD
            finv[i] = finv[i-1]*inv[i]%MOD

    def com(n, k):
        if n < 0:return 0
        elif k > n: return 0
        
        return (fac[n]*finv[n-k]%MOD)*finv[k]%MOD
    
    k = min(k, N-1)
    ans = 1
    com_init()
    for i in range(1, k+1):
        ans += com(N, i)*com(N-1, N-i-1)
        ans %= MOD
    print(ans) def main():
    N, k = map(int, input().split())

    MAX_N = 3 * 10 ** 5
    MOD = 10 ** 9 + 7
    fac = [0]*MAX_N
    inv = [0]*MAX_N
    finv = [0]*MAX_N
    fac[0] = 1; fac[1] = 1
    inv[1] = 1
    finv[0] = 1; finv[1] = 1

    def com_init():
        for i in range(2, MAX_N):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = -(MOD//i)*inv[MOD%i]%MOD
            finv[i] = finv[i-1]*inv[i]%MOD

    def com(n, k):
        if n < 0:return 0
        elif k > n: return 0
        
        return (fac[n]*finv[n-k]%MOD)*finv[k]%MOD
    
    k = min(k, N-1)
    ans = 1
    com_init()
    for i in range(1, k+1):
        ans += com(N, i)*com(N-1, N-i-1)
        ans %= MOD
    print(ans) main
def main():
    N, k = map(int, input().split())

    MAX_N = 3 * 10 ** 5
    MOD = 10 ** 9 + 7
    fac = [0]*MAX_N
    inv = [0]*MAX_N
    finv = [0]*MAX_N
    fac[0] = 1; fac[1] = 1
    inv[1] = 1
    finv[0] = 1; finv[1] = 1

    def com_init():
        for i in range(2, MAX_N):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = -(MOD//i)*inv[MOD%i]%MOD
            finv[i] = finv[i-1]*inv[i]%MOD

    def com(n, k):
        if n < 0:return 0
        elif k > n: return 0
        
        return (fac[n]*finv[n-k]%MOD)*finv[k]%MOD
    
    k = min(k, N-1)
    ans = 1
    com_init()
    for i in range(1, k+1):
        ans += com(N, i)*com(N-1, N-i-1)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()