(a^b)%c

Time complexity O(logb)