'use strict'

function main(input) {

    input = input.split(/\s|\n/).map(v => ~~v)
    let ans = input[0] - input[1]
    console.log(ans % input[2])

}

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