https://www.acmicpc.net/problem/1629
시간 제한 : 0.5초
메모리 제한 : 128MB
a, b, c = map(int, input().split(' '))
def multi(a, n):
if n == 1:
return a % c
else:
temp = multi(a, n//2)
if n % 2 == 0: # 짝수일 경우
return (temp * temp) % c
else: # 홀수일 경우
return (temp * temp * a) % c
print(multi(a, b))