const main = () => {
  const xab = getParams()
      , x = xab[0]
      , a = xab[1]
      , b = xab[2];
  console.log(solve(x, a, b));
};

const getParams = () =>
  getStdin().split('\n').map(Number);

const getStdin = () =>
  require('fs').readFileSync('/dev/stdin', 'utf8').trim();

const solve = (x, a, b) =>
  (x - a) % b;

main();
