#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
void qmi(ll x,ll y){
ll res=1;
while(y){
if(res>1000000000){
printf("-1");
return ;
}
if(y&1){
res=res*x;
y--;
}
if(y==0){
break;
}
x=x*x;
if(x>1000000000){
printf("-1");
return ;
}
y>>=1;
}
printf("%lld",res);
return ;
}
int main(){
scanf("%lld%lld",&a,&b);
if(a==1){
printf("1");
return 0;
}
if(a>1000000000){
printf("-1");
return 0;
}
qmi(a,b);
return 0;
}