//主要思路就是快速幂
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a,b,m;
LL binaryPow(LL a,LL b,LL m)
{
LL ans = 1;
if(b==0){
return 1%m;
}
while(b>0){
if(b & 1){
ans = ans *a %m;
}
a= a*a%m;
b >>= 1;
}
return ans;
}
int main()
{
cin>>a>>b>>m;
LL result = binaryPow(a,b,m);
cout<<result<<endl;
return 0;
}