object Main extends App {
  val sc = new java.util.Scanner(System.in)
//  val l = List.fill(3)(sc.nextInt)
  val x = sc.nextInt
  val a = sc.nextInt
  val b = sc.nextInt

  val ans = (x - a) % b
  println(ans)
}