#include <iostream>
#define MOD 1000000007LL

using namespace std;

typedef long long ll;

ll hoge_pow(ll m, ll n) {
	if(n==1) return m;
	ll ret = hoge_pow(m,n/2);
	ret = (ret*ret)%MOD;
	if(n%2==1) {
		ret = (ret*m)%MOD;
	}
	return ret;
}

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

