mod = 10 ** 9 + 7 n, k = map(int, input().split()) fact = [1] * (n + 1) permk = [1] * (n + 1) pow2 = [1] * (n + 1) for i in range(n): fact[i + 1] = fact[i] * (i + 1) % mod permk[i + 1] = permk[i] * (k - i) % mod pow2[i + 1] = pow2[i] * 2 % mod ifact = [1] * (n + 1) ifact[n] = pow(fact[n], mod - 2, mod) for i in range(n)[::-1]: ifact[i] = ifact[i + 1] * (i + 1) % mod ans = 0 for i in range(n): ans += permk[n - i] * ifact[n - i] % mod * fact[n - 1] % mod * ifact[n - 1 - i] % mod * ifact[i] % mod * pow2[n - 1 - i] ans %= mod print(ans)