#include <bits/stdc++.h>
using namespace std;
int qmi(int m,int k,int p){
int res=1%p,t=m;
while(k){
if(k&1) res=((long long) res*t)%p;
t=((long long) t*t)%p;
k>>=1;
}
return res;
}
int main(){
int a,b,c;
cin>>a>>b>>c;
cout<<qmi(a,b,c)<<endl;
}