#include using namespace std; using ll = long long; using pii = pair; const ll mod = 129402307; string N, M; ll mod_pow(ll x, ll n, ll mod) { if (n == 0) return 1; ll res = mod_pow(x * x % mod, n / 2, mod); if (n & 1) res = res * x % mod; return res; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin >> N >> M; ll n = 0; for (int i = 0; i < N.size(); i++) { n = (n * 10 + N[i] - '0') % mod; } ll m = 0; for (int i = 0; i < M.size(); i++) { m = (m * 10 + M[i] - '0') % (mod - 1); } cout << (n == 0 ? 0 : mod_pow(n, m, mod)) << endl; return 0; }