#includelonglongint base;//底数longlongint exp_1;//指数longlongint mod;//取模数longlongMontgomery(){longlongint res =1;while(exp_1){if(exp_1&1)//如果为奇数
res =(res*base)% mod;
exp_1 >>=1;//指数对半
base =(base*base)% mod;//底数平方}return res;}intmain(){scanf("%I64d%I64d%I64d",&base,&exp_1,&mod);printf("%I64d",Montgomery());return0;}