#include <iostream>
using namespace std;
int a,b;
typedef long long ll;
ll quical(ll a,ll b)
{
ll ret = 1;
while(b)
{
if(a>1e9) return -1;
if(b&1)
{
ret*=a;
if(ret>1e9) return -1;
}
a*=a;
b>>=1;
}
return ret;
}
int main()
{
cin >> a >> b;
cout << quical(a,b);
return 0;
}