function Main(input) {
  var X = parseInt(input.split("\n")[0]);
  var A = parseInt(input.split("\n")[1]);
  var B = parseInt(input.split("\n")[2]);
  console.log((X - A) % B);
}

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