    function main(input){
        const nums = input.split(/\n/).map(str=>{return Number(str)});
        console.log((nums[0] - nums[1]) % nums[2]);
    }
    main(require('fs').readFileSync('/dev/stdin','utf-8'));