#include using namespace std; typedef long long ll; ll modstr(string const & s, ll m){ ll a = 0; for(auto c:s) a = (c-'0'+a*10) % m; return a; } ll modpow(ll x, ll y, ll m){ if(y==0) return 1; ll res = modpow(x,y/2,m); return res * res % m * (y&1 ? x : 1) % m; }; ll modpow(string const & s, string const & t, ll m){ assert(s != "0" || t != "0"); ll N = modstr(s,m); if(N==0) return t == "0" ? 1 : 0; else return modpow(N,modstr(t,m-1),m); } int main(){ string s,t; cin >> s >> t; cout << modpow(s,t,129402307) << endl; }