#include using namespace std; typedef long long ll; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef pair< int, int > pii; typedef vector< pii > vp; typedef vector< double > vd; typedef vector< vd > vvd; typedef vector< string > vs; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; const int MOD = 129402307; string N, M; void init(){ cin >> N >> M; } int n, m; void preprocess(){ for( int i = 0; i < N.size(); ++i ) n = ( 1LL * n * 10 + N[ i ] - '0' ) % MOD; for( int i = 0; i < M.size(); ++i ) m = ( 1LL * m * 10 + M[ i ] - '0' ) % ( MOD - 1 ); } int int_pow( int v, int p ){ int res = 1; while( p ){ if( p & 1 ) res = 1LL * res * v % MOD; p >>= 1; v = 1LL * v * v % MOD; } return res; } void solve(){ cout << int_pow( n, m ) << endl; } signed main(){ ios::sync_with_stdio( 0 ); init(); preprocess(); solve(); return 0; }