include[HTML_REMOVED]
using namespace std;
long long quickexp(long long base,long long exp,long long mod)
{
long long ans=1;
while(exp)
{
if(exp&1)
ans=( (ans%mod)*(base%mod) )%mod;
base=( (base%mod) * (base%mod) ) %mod;
exp=exp>>1;
}
return ans%mod;
}
int main()
{
long long a,b,c;
cin>>a>>b>>c;
cout<<quickexp(a,b,c)<<endl;
return 0;
}