object Main {
	def main(args:Array[String]) = {
		val sc = new java.util.Scanner(System.in)
		val wallet = sc.nextInt
		val donuts_a = sc.nextInt
		val donuts_b = sc.nextInt
		
		println((wallet - donuts_a) % donuts_b)
	}
}