#include <bits/stdc++.h>
using namespace std;
#define LL long long
LL power_mod(LL a,LL b, LL mod)
{
LL res = 1;
a %= mod;
while(b){
if(b & 1) res = (res * a)%mod;
b<<=1;//等效于b/=2;
a = (a*a) % mod;
}
return res;
}
int main()
{
LL a,b,mod;
cin>>a>>b>>mod;
int res = power_mod(a,b,mod);
cout<<res<<endl;
return 0;
}