#include<iostream> using namespace std; #define ll long long ll a,b,c; ll pw(ll x,ll n,ll p){ ll result=1; while(n){ if(n&1)result=(result*x)%p; n>>=1; x=(x*x)%p; } return result%p; } int main(){ cin>>a>>b>>c; cout<<pw(a,b,c); }