'use strict'

function main(s) {

  s = s.split('\n');
  const x = Number(s[0]);
  const a = Number(s[1]);
  const b = Number(s[2]);

  const ans = (x - a) % b;
  console.log(ans);
}

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