'use strict'

function main(input) {
  input = input
    .trim()
    .split('\n')
    .map(v => Number(v))
  const ans = (input[0] - input[1]) % input[2]
  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

