include”iostream”
using namespace std;
int f(int a, int b, int p)
{
int res = 1;
while (b)
{
if(b&1)res = (long long)res * a % p;
b >>= 1;
a = (long long)a * a%p;
}
return res%p;
}
int main()
{
int a, b, p;
cin >> a >> b >> p;
int res = f(a, b, p);
cout << res << endl;
return 0;
}