#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll modpow(ll m, ll n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
    {
      res = res * m % mod;
    }
    m = m * m % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  ll m, n;
  cin >> m >> n;
  cout << modpow(m, n) << endl;
}
