'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	let x = parseInt(args[0][0], 10)
	const a = parseInt(args[1][0], 10)
	const b = parseInt(args[2][0], 10)
	x -= a
	x -= b * Math.floor(x / b)
	console.log(x)
}

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