/* kxxxxxxxxxxxxxkkkxxxxxxkkxxxxkkkkkkkxxxxxkkO0K00000000000OO0000000000000000OOOOkkOOOOOOOkc'.',;;;;;;;;;;,,,,,,, kxxxxxxxxxxxxkkkkxxxxxxxxxxxxkkkkkkxxxxkO0KKKK0000000000000000000000000000K000OOOOkOOOOOkc''';;;;;;;;;;;;;,,,,, kkkxxxxxxxxxxkkkkkxxxxxxxxxxxxkkkkxkkO000K000KKKK0Oxxxxxk00000000OxxxkO00KKKKK00OOOOOO00Ol,',;;;;;;;;;;;;;;,,,, kkkkkxxxxxxxxxkkxxxxxxxxxxkxxkkkkkO000KKK0000KKOkxxkOO0KK0000OOO000OOkxxk000KK0KK00000O0Ol,',;;;;;;;;;;;;;;,,,, kkkkkkxxxxxxxxkkkxxxxxxkkkkkkkkk0KKKKKKKKKKK0Okkk00KKKKXKKK0Ok00O0KXKK0Okxk0KKKKKKKKKKK0Ol,',;:;;;;;;;;;;;;;,,, kkkkkxxxxxxxxkkkkkkkkkkkkkkkkkOKXXXXXKKKKKKK000KKKKKKKKKKKKK0kOK00KKKKKKK0OkOKXKKXXXXKKKKd;',;;;;;;;;;;;;;;;;;, kkkkkkxxxxxxxkkkkkkkkkkkkkkkk0XXXXXXXXXXXKKKKXXXXXXXK0KKKKKKXK0KK0KXKXXXXXXKOk0XXXXXXXXKXKd;;;:::::::::::::;;;; kkkkkkkkxxxxxkkkkkkkkkkkkkkOKXNNXNNNXXXXKKKXXXXXXXXXKKXXXXXXXXKKK0KXXXXXXXXXXKO0XXXXXXXXKXXkdoddooooooooooooooo kkkkkkkkkkkkkkkkkkkkkkkkkkOKXNNXNWNNNXXXKXNXXXXNNXXKKXXXXXXXXXKXX00XXXXXXXXNXNXKKXNNXXNNXKXX0xxxxdxxxxxxxdddddd kkkkkkkkkkkkkkkkkkkOOkkkkOKNNWNXWWWNNXKKNWNXXNWWNXXKXXXXXXXXXXXXXKKXXNNXXNNNXXNNXKXNNNXNNXKXX0xxdc::::::::::::: kkkk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kOXXKKXXXXXXXXXXXXXK0koccc kkkkkkkkOOkk0XXKKXXXXXXXXXXXXK000KXKKOxkxddd0WNXXd;,:xXWWWNNWWNNWWWKl,;xKNWWXxdddddkOxOXNKKXXXXXXXXXXXXXKKXOocl kkkkkkkkOOkOKXXXKKXXXXXXXXXKOkOXNXXXNOdxdoooO00KXKo,.':lxXWXXNNNWKd;':kXXKKNXxoddddOxdOKNX0KXXXXXXXXXXXKKXXXkdd kkkkkkkkOOkOKXXXXKKXXXXXXXXKkdk0KXNNXkoxddxdc:::cc:,''''':d00O0Oo,'',cllllclolooookOxk0KNNkkKXXXXXXXXXKKXXXX0xd kkkkkkOOOOk0XXXXXKKXXXXXXXXXK0kx0NNWXxdk0XNk:,,,,,,,,,,,,,';:::,'',,,,,,,,,;,ckkdok000KXNWK0XXXXXXXXXXKKXXXXKxd kkkkkOOOOOk0XXXXXXKKXXXXXXXXXKOkKNNWKKK000Oo;,,,,,,,,,,,''..','....',,,,,,,,,:kXX0OkxkKXNNXKXXXXXXXXXKKXXXXXKkd kkkkOOOOOOO0XXXXXXKKXXXXXXX0kxdxKNNNXXKkdodl,,,,,,,,,,,,,'''','....',,,,,,,,,;ok0K00kkKNNNXKXXXXXXXXKKKXXXXXXOd */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace __gnu_pbds; #define ll long long #define ldb long double #define fi first #define se second #define ARYA solve() #define pb push_back #define mp make_pair #define ii pair #define pli pair #define pll pair #define pil pair #define floorz floor #define plii pair>rb_cay_tag, cay_order_statistics_u_update> #define HNgaaNe ios::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); #define sz(x) (ll)x.size() #define all(x) (x).begin(),(x).end() #define rsort(x) (x).rbegin(),(x).rend() #define all2(x) (x) + 1, (x) + n + 1 #define Nan -1 #define init int main() #define inf 1000000000000000000 const long long mod = 1e9 + 7; const int base = 7001; const ldb PI = acos(-1.0); const int N = 500005; const int N_trie = 1e5; const int N_st = 2e5 + 10; const int N_bIt = 2e5 + 10; const int ooint = (1ll << 31) - 1; const int logn = 20; const int lImid = 1e7; // N_prime const int N_midst = 1e5; // N of miderge sort cay const int N_hash = 2e6 + 10; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } ll sn(ll n) { ll s = 0; while (n > 0) { s += n % 10; n /= 10; } return s; } ll pO(ll x) { return x * x;} ll powe(ll a, ll b) { if (b == 0) return 1; else{ if (b % 2 == 0) return pO(pow(a, b / 2)); else return a * (pO(pow(a, b / 2))); } } ll snt[lImid + 2]; void sieve() { for(ll i = 1; i <= lImid; i++) snt[i] = 0; for(ll i = 1; i <= lImid; i++) { for(ll j = i; j <= lImid; j += i) { snt[j] += i; } } } ll mul(ll a, ll b, ll c){ // O(log(min(a,b))) if (a < b) swap(a, b); ll res = 0; a = a % c; for (; b > 0; b >>= 1 , a = (a + a) % c){ if (b & 1) res = (res + a) % c; } return res; } ll po(ll a,ll b,ll c){ // O(log(b)) ll res = 1; a = a % c; for (; b > 0; b >>= 1 , a = a * a % c){ if (b & 1) res = res * a % c; } return res; } ll po_mul(ll a, ll b, ll c){ // O(log(b)^2) ll res = 1; a = a % c; for (; b > 0; b >>= 1 , a = mul(a, a, c)){ if (b & 1) res = mul(res, a, c); } return res; } void file(const string FILE){ if (fopen((FILE + ".INP").c_str(),"r")){ freopen((FILE + ".INP").c_str(), "r", stdin); freopen((FILE + ".OUT").c_str(), "w", stdout); } } ll phi(ll m) { ll res = m; for (ll i = 2; i * i <= m; i++) { if (m % i == 0) { while (m % i == 0) m /= i; res -= res / i; } } if (m > 1) res -= res / m; return res; } ll ptm(ll a, ll n, ll m) { if (m == 1) return 0; if (n == 0) return 1; if (n == 1) return a % m; ll phi_m = phi(m), exponent = ptm(a, n - 1, phi_m); return po_mul(a, exponent, m); } void ARYA{ ll a, n, m; cin >> a >> n >> m; cout << ptm(a, n, m); } init{ //file("skibiditoilet"); HNgaaNe int _ = 1; //cin >> _; while (_--){ ARYA; } return 0; }