import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

fun solve(sc: Scanner): String {
    val X = sc.nextInt()
    val A = sc.nextInt()
    val B = sc.nextInt()

    return ((X - A) % B).toString()
}
