#include<bits/stdc++.h>
using namespace std;
#define endl “\n”
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long int
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int fastexponentiation(int a,int b,int c)
{
int ans=1;
while(b>0)
{
if(b&1)
{
ans=(ansa)%c;
}
a=(aa)%c;
b=b>>1;
}
return ans;
}
int main()
{
/#ifndef ONLINE_JUDGE
freopen(“input.txt”, “r”, stdin);
freopen(“output.txt”, “w”, stdout);
#endif/
int a,b,c;
cin>>a>>b>>c;
int ans=fastexponentiation(a,b,c);
cout<<(ans+c)%c;
return 0;
}
my code