import sys
input = sys.stdin.readline

MOD = 10 ** 9 + 7

def main():
    N, K = (int(_) for _ in input().split())

    fact = [0] * (N + 1) # fact[n] = n!
    ifact = [0] * (N + 1)
    
    for i in range(N+1):
        if i == 0:
            fact[i] = 1
            continue
        fact[i] = i * fact[i-1]
        fact[i] %= MOD
    ifact[N] = pow(fact[N], MOD-2, MOD)
    for i in range(N)[::-1]:
        ifact[i] = ((i+1) * ifact[i+1])%MOD

    ret = 0
    for m in range(min(K, N-1) + 1):
        ret += (fact[N] * ifact[m] * ifact[N-m])%MOD * (fact[N-1] * ifact[N-m-1] * ifact[m])%MOD
        ret %= MOD
    print(ret%MOD)

    return

if __name__ == '__main__':
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def main():
    N, K = (int(_) for _ in input().split())

    fact = [0] * (N + 1) # fact[n] = n!
    ifact = [0] * (N + 1)
    
    for i in range(N+1):
        if i == 0:
            fact[i] = 1
            continue
        fact[i] = i * fact[i-1]
        fact[i] %= MOD
    ifact[N] = pow(fact[N], MOD-2, MOD)
    for i in range(N)[::-1]:
        ifact[i] = ((i+1) * ifact[i+1])%MOD

    ret = 0
    for m in range(min(K, N-1) + 1):
        ret += (fact[N] * ifact[m] * ifact[N-m])%MOD * (fact[N-1] * ifact[N-m-1] * ifact[m])%MOD
        ret %= MOD
    print(ret%MOD)

    return main int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ N, K = (int(_) for _ in input().split()) N (int(_) for _ in input().split()) K fact = [0] * (N + 1) fact [0] * (N + 1) [0] 0 N + 1 N 1 ifact = [0] * (N + 1) ifact [0] * (N + 1) [0] 0 N + 1 N 1 for i in range(N+1):
        if i == 0:
            fact[i] = 1
            continue
        fact[i] = i * fact[i-1]
        fact[i] %= MOD
     i range(N+1) range N+1 N 1 if i == 0:
            fact[i] = 1
            continue
         i == 0 i 0 fact[i] = 1 fact[i] fact i 1 continue fact[i] = i * fact[i-1] fact[i] fact i i * fact[i-1] i fact[i-1] fact i-1 i 1 fact[i] %= MOD fact[i] fact i MOD ifact[N] = pow(fact[N], MOD-2, MOD) ifact[N] ifact N pow(fact[N], MOD-2, MOD) pow fact[N] fact N MOD-2 MOD 2 MOD for i in range(N)[::-1]:
        ifact[i] = ((i+1) * ifact[i+1])%MOD

     i range(N)[::-1] (N) range N ::-1 -1 ifact[i] = ((i+1) * ifact[i+1])%MOD ifact[i] ifact i ((i+1) * ifact[i+1])%MOD (i+1) * ifact[i+1] i+1 i 1 ifact[i+1] ifact i+1 i 1 MOD ret = 0 ret 0 for m in range(min(K, N-1) + 1):
        ret += (fact[N] * ifact[m] * ifact[N-m])%MOD * (fact[N-1] * ifact[N-m-1] * ifact[m])%MOD
        ret %= MOD
     m range(min(K, N-1) + 1) range min(K, N-1) + 1 min(K, N-1) min K N-1 N 1 1 ret += (fact[N] * ifact[m] * ifact[N-m])%MOD * (fact[N-1] * ifact[N-m-1] * ifact[m])%MOD ret (fact[N] * ifact[m] * ifact[N-m])%MOD * (fact[N-1] * ifact[N-m-1] * ifact[m])%MOD (fact[N] * ifact[m] * ifact[N-m])%MOD * (fact[N-1] * ifact[N-m-1] * ifact[m]) (fact[N] * ifact[m] * ifact[N-m])%MOD fact[N] * ifact[m] * ifact[N-m] fact[N] * ifact[m] fact[N] fact N ifact[m] ifact m ifact[N-m] ifact N-m N m MOD fact[N-1] * ifact[N-m-1] * ifact[m] fact[N-1] * ifact[N-m-1] fact[N-1] fact N-1 N 1 ifact[N-m-1] ifact N-m-1 N-m N m 1 ifact[m] ifact m MOD ret %= MOD ret MOD print(ret%MOD) print ret%MOD ret MOD return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main input = sys.stdin.readline sys.stdin.readline input def main():
    N, K = (int(_) for _ in input().split())

    fact = [0] * (N + 1) # fact[n] = n!
    ifact = [0] * (N + 1)
    
    for i in range(N+1):
        if i == 0:
            fact[i] = 1
            continue
        fact[i] = i * fact[i-1]
        fact[i] %= MOD
    ifact[N] = pow(fact[N], MOD-2, MOD)
    for i in range(N)[::-1]:
        ifact[i] = ((i+1) * ifact[i+1])%MOD

    ret = 0
    for m in range(min(K, N-1) + 1):
        ret += (fact[N] * ifact[m] * ifact[N-m])%MOD * (fact[N-1] * ifact[N-m-1] * ifact[m])%MOD
        ret %= MOD
    print(ret%MOD)

    return def main():
    N, K = (int(_) for _ in input().split())

    fact = [0] * (N + 1) # fact[n] = n!
    ifact = [0] * (N + 1)
    
    for i in range(N+1):
        if i == 0:
            fact[i] = 1
            continue
        fact[i] = i * fact[i-1]
        fact[i] %= MOD
    ifact[N] = pow(fact[N], MOD-2, MOD)
    for i in range(N)[::-1]:
        ifact[i] = ((i+1) * ifact[i+1])%MOD

    ret = 0
    for m in range(min(K, N-1) + 1):
        ret += (fact[N] * ifact[m] * ifact[N-m])%MOD * (fact[N-1] * ifact[N-m-1] * ifact[m])%MOD
        ret %= MOD
    print(ret%MOD)

    return main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
import sys
input = sys.stdin.readline

MOD = 10 ** 9 + 7

def main():
    N, K = (int(_) for _ in input().split())

    fact = [0] * (N + 1) # fact[n] = n!
    ifact = [0] * (N + 1)
    
    for i in range(N+1):
        if i == 0:
            fact[i] = 1
            continue
        fact[i] = i * fact[i-1]
        fact[i] %= MOD
    ifact[N] = pow(fact[N], MOD-2, MOD)
    for i in range(N)[::-1]:
        ifact[i] = ((i+1) * ifact[i+1])%MOD

    ret = 0
    for m in range(min(K, N-1) + 1):
        ret += (fact[N] * ifact[m] * ifact[N-m])%MOD * (fact[N-1] * ifact[N-m-1] * ifact[m])%MOD
        ret %= MOD
    print(ret%MOD)

    return

if __name__ == '__main__':
    main()
