// competitive-verifier: PROBLEM https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B
#include "Math/mod_power.hpp"
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long m, n;
cin >> m >> n;
cout << mod_pow<long long>(m, n, 1000000007) << endl;
return 0;
}
#line 1 "test/Math/mod_power/aoj-NTL_1_B.cpp"
// competitive-verifier: PROBLEM https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B
#line 1 "Math/mod_power.hpp"
#include <bits/stdc++.h>
using namespace std;
#line 2 "Other/fast_power.hpp"
using namespace std;
template <class S>
S fast_pow(S x, long long n, function<S(S, S)> mul, function<S()> e)
{
assert(0 <= n);
S ans = e();
while (n)
{
if (n & 1)
{
ans = mul(ans, x);
}
x = mul(x, x);
n >>= 1;
}
return ans;
}
#line 5 "Math/mod_power.hpp"
template <typename T>
enable_if_t<is_integral_v<T> || is_same_v<T, __int128_t>, T>
mod_pow(T x, T n, T mod)
{
assert(0 <= n);
assert(0 < mod);
assert(mod <= numeric_limits<T>::max() / mod);
x %= mod;
if (x < 0)
{
x += mod;
}
auto mul = [&](T a, T b) -> T
{
return (a * b) % mod;
};
auto e = [&]() -> T
{
return 1;
};
return fast_pow<T>(x, n, mul, e);
}
#line 5 "test/Math/mod_power/aoj-NTL_1_B.cpp"
using namespace std;
int main()
{
long long m, n;
cin >> m >> n;
cout << mod_pow<long long>(m, n, 1000000007) << endl;
return 0;
}