function main(input) {
    const X = input.split('\n')[0];
    const A = input.split('\n')[1];
    const B = input.split('\n')[2];
    const ans = (X - A) % B;
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));