const fs = require('fs');
// Node.js 中 Number 能够正常使用的最大整数是 Number.MAX_SAFE_INTEGER=2^53-1
// 这里 a、b 的最大值是 10^18,a*b 在 10^36 左右,超过了 Number 能够正常使用的最大值
// 因此需要使用 BigInt
// 注意这里不能先 parseInt(x) 再转换为 BigInt,parseInt 的时候数据已经不对了
const [a, b, p] = fs.readFileSync(0, 'utf-8').trim().split('\n').map((x) => BigInt(x.trim()));
console.log((a * b % p).toString());