object Main {

	def main(arg:Array[String]) = {
		val x = scala.io.StdIn.readLine().toInt;
		val a = scala.io.StdIn.readLine().toInt;
		val b = scala.io.StdIn.readLine().toInt;
		println((x - a) % b);
	}

}