import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val x = br.readLine().toInt()
    val a = br.readLine().toInt()
    val b = br.readLine().toInt()
    println((x - a) % b)
}

fun err(print: Any) {
    System.err.println(print)
}