1 // power
2 #include<cstdio>
3 #include<cstdlib>
4 #include<cstring>
5 #include<iostream>
6 #include<algorithm>
7 #include<queue>
8 #include<cmath>
9 using namespace std;
10 typedef long long ll;
11 ll power (int a,int b,int m)
12 {
13 ll ret=1,t=a;
14 while (b)
15 {
16 if(b&1){
17 ret*=t;
18 ret%=m;
19 }
20 b>>=1;
21 t*=t;
22 t%=m;
23 }
24 return ret%m;
25 }
26 int main()
27 {
28 freopen("1.in","r",stdin);
29 freopen("1.out","w",stdout);
30 int n,m,mod;
31 cin>>n>>m>>mod;
32 ll ans=power(n,m,mod);
33 cout<<ans<<endl;
34 return 0;