//https://ncode.syosetu.com/n4830bu/251/
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;

const ll mod = 129402307;

int main() {
    cpp_int N, M;
    cin >> N >> M;
    if (M == 0) {
        cout << 1 << endl;
        return 0;
    }
    N %= mod;
    M %= (mod - 1);
    cpp_int ans = 1;
    if (N == 0 && M == 0)
        ans = 0;
    while (M) {
        if (M % 2 == 1) {
            ans *= N;
            ans %= mod;
        }
        N *= N;
        N %= mod;
        M /= 2;
    }
    cout << ans << endl;
}