#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
int max_ans=1e9;
int qpow(int a,int b){
if(b==1) return a;
if(b==0) return 1;
if(b%2==0){
int x=qpow(a,b/2)*qpow(a,b/2);
if(x>max_ans){
cout<<-1;
exit(0);
}
return x;
}
int x=a*qpow(a,b/2)*qpow(a,b/2);
if(x>max_ans){
cout<<-1;
exit(0);
}
return x;
}
signed main(){
freopen("pow.in","r",stdin);
freopen("pow.out","w",stdout);
cin>>n>>m;
cout<<qpow(n,m);
return 0;
}