mod=10**9+7 n,m=map(int,input().split()) ans=0 tmp=1 for i in range(n): tmp*=(m-i) tmp%=mod ans+=tmp for i in range(m,n,-1): tmp*=pow(i,mod-2,mod) tmp*=(i-n) tmp%=mod ans+=tmp ans%=mod div=1 for i in range(1,n+1): div*=i div%=mod div=pow(div,mod-2,mod) print((ans*div)%mod)