
fun readLineInt(): Int {
    val str: String? = readLine()
    return if (str == null) 0 else str.toInt()
}

fun main(arg: Array<String>) {
    val x: Int = readLineInt()
    val a: Int = readLineInt()
    val b: Int = readLineInt()
    val rest: Int = x - a
    val num: Int = rest / b
    println(rest - num * b)
}
