import scala.io.StdIn

object Main extends App {
   val n = StdIn.readLine().toInt
   val a = StdIn.readLine().toInt
   val b = StdIn.readLine().toInt
   
   val r = (n - a) % b
   
   println(if(0 <= r) r else 0)
}
