mo=10^9+7
main=do
 [n,k]<-map read.words<$>getLine
 print$f 0 1 1(min(n-1)k)n
p a n
 |n==0=1
 |even n=p(a*a`mod`mo)(div n 2)
 |odd n=a*(p a$n-1)`mod`mo
f i x y lim n
 |i==lim=x*y`mod`mo
 |i<lim=(x*y`mod`mo+f(i+1)(x*(n-i)`mod`mo*r`mod`mo)(y*(n-i-1)`mod`mo*r`mod`mo)lim n)`mod`mo where r=p(i+1)(mo-2)