def main():
    n,k=map(int,input().split())
    MOD=10**9+7

    def pre(n,MOD):
        a=1
        for i in range(1,n+1):
            a=(a*i)%MOD
        an=a
        b=pow(a,MOD-2,MOD)
        bs=[1]*(n+1)
        bs[n]=b
        for i in range(n,1,-1):
            b=b*i%MOD
            bs[i-1]=b
        return an,bs

    a,b=pre(n-1,MOD)
    ans=1
    for i in range(1,min(n-1,k)+1):
        s=(a*n*b[i])%MOD
        s=(s*b[n-i])%MOD
        s=(s*a*b[n-i-1])%MOD
        s=(s*b[i])%MOD
        ans+=s
        ans%=MOD
    print(ans)
    
if __name__ == '__main__':
    main() def main():
    n,k=map(int,input().split())
    MOD=10**9+7

    def pre(n,MOD):
        a=1
        for i in range(1,n+1):
            a=(a*i)%MOD
        an=a
        b=pow(a,MOD-2,MOD)
        bs=[1]*(n+1)
        bs[n]=b
        for i in range(n,1,-1):
            b=b*i%MOD
            bs[i-1]=b
        return an,bs

    a,b=pre(n-1,MOD)
    ans=1
    for i in range(1,min(n-1,k)+1):
        s=(a*n*b[i])%MOD
        s=(s*b[n-i])%MOD
        s=(s*a*b[n-i-1])%MOD
        s=(s*b[i])%MOD
        ans+=s
        ans%=MOD
    print(ans)
     main n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 def pre(n,MOD):
        a=1
        for i in range(1,n+1):
            a=(a*i)%MOD
        an=a
        b=pow(a,MOD-2,MOD)
        bs=[1]*(n+1)
        bs[n]=b
        for i in range(n,1,-1):
            b=b*i%MOD
            bs[i-1]=b
        return an,bs

     pre a=1 a 1 for i in range(1,n+1):
            a=(a*i)%MOD
         i range(1,n+1) range 1 n+1 n 1 a=(a*i)%MOD a (a*i)%MOD a*i a i MOD an=a an a b=pow(a,MOD-2,MOD) b pow(a,MOD-2,MOD) pow a MOD-2 MOD 2 MOD bs=[1]*(n+1) bs [1]*(n+1) [1] 1 n+1 n 1 bs[n]=b bs[n] bs n b for i in range(n,1,-1):
            b=b*i%MOD
            bs[i-1]=b
         i range(n,1,-1) range n 1 -1 b=b*i%MOD b b*i%MOD b*i b i MOD bs[i-1]=b bs[i-1] bs i-1 i 1 b return an,bs return an,bs an bs n n MOD MOD a,b=pre(n-1,MOD) a pre(n-1,MOD) pre n-1 n 1 MOD b ans=1 ans 1 for i in range(1,min(n-1,k)+1):
        s=(a*n*b[i])%MOD
        s=(s*b[n-i])%MOD
        s=(s*a*b[n-i-1])%MOD
        s=(s*b[i])%MOD
        ans+=s
        ans%=MOD
     i range(1,min(n-1,k)+1) range 1 min(n-1,k)+1 min(n-1,k) min n-1 n 1 k 1 s=(a*n*b[i])%MOD s (a*n*b[i])%MOD a*n*b[i] a*n a n b[i] b i MOD s=(s*b[n-i])%MOD s (s*b[n-i])%MOD s*b[n-i] s b[n-i] b n-i n i MOD s=(s*a*b[n-i-1])%MOD s (s*a*b[n-i-1])%MOD s*a*b[n-i-1] s*a s a b[n-i-1] b n-i-1 n-i n i 1 MOD s=(s*b[i])%MOD s (s*b[i])%MOD s*b[i] s b[i] b i MOD ans+=s ans s 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())
    MOD=10**9+7

    def pre(n,MOD):
        a=1
        for i in range(1,n+1):
            a=(a*i)%MOD
        an=a
        b=pow(a,MOD-2,MOD)
        bs=[1]*(n+1)
        bs[n]=b
        for i in range(n,1,-1):
            b=b*i%MOD
            bs[i-1]=b
        return an,bs

    a,b=pre(n-1,MOD)
    ans=1
    for i in range(1,min(n-1,k)+1):
        s=(a*n*b[i])%MOD
        s=(s*b[n-i])%MOD
        s=(s*a*b[n-i-1])%MOD
        s=(s*b[i])%MOD
        ans+=s
        ans%=MOD
    print(ans)
     def main():
    n,k=map(int,input().split())
    MOD=10**9+7

    def pre(n,MOD):
        a=1
        for i in range(1,n+1):
            a=(a*i)%MOD
        an=a
        b=pow(a,MOD-2,MOD)
        bs=[1]*(n+1)
        bs[n]=b
        for i in range(n,1,-1):
            b=b*i%MOD
            bs[i-1]=b
        return an,bs

    a,b=pre(n-1,MOD)
    ans=1
    for i in range(1,min(n-1,k)+1):
        s=(a*n*b[i])%MOD
        s=(s*b[n-i])%MOD
        s=(s*a*b[n-i-1])%MOD
        s=(s*b[i])%MOD
        ans+=s
        ans%=MOD
    print(ans)
     main
def main():
    n,k=map(int,input().split())
    MOD=10**9+7

    def pre(n,MOD):
        a=1
        for i in range(1,n+1):
            a=(a*i)%MOD
        an=a
        b=pow(a,MOD-2,MOD)
        bs=[1]*(n+1)
        bs[n]=b
        for i in range(n,1,-1):
            b=b*i%MOD
            bs[i-1]=b
        return an,bs

    a,b=pre(n-1,MOD)
    ans=1
    for i in range(1,min(n-1,k)+1):
        s=(a*n*b[i])%MOD
        s=(s*b[n-i])%MOD
        s=(s*a*b[n-i-1])%MOD
        s=(s*b[i])%MOD
        ans+=s
        ans%=MOD
    print(ans)
    
if __name__ == '__main__':
    main()