#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL mypow(LL a,LL b,LL c){
LL sum=1;
while(b){
if(b&1) sum=sum*a%c;
a=a*a%c;
b>>=1;
}
return sum;
}
int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("%lld\n",mypow(a,b,c));
}