fun main(args:Array<String>?): Unit {
    val (a, b, k) = readLine()!!.trim().split(' ').map(String::toInt)
    println(solve(a, b, k))
}
fun solve(a: Int, b: Int, k: Int): Int {
    val aDigits = (10000000000L + a).toString().drop(1).map{it - '0'}.toIntArray()
    val bDigits = (10000000000L + b).toString().drop(1).map{it - '0'}.toIntArray()
    val memo = Array(2){Array(k + 1){Array(aDigits.size){null as Int?}}}
    fun sub(digit: Int, restK: Int, borrow: Int = 0): Int {
        if (digit < 0) return 0
        if (memo[borrow][restK][digit] != null) return memo[borrow][restK][digit]!!
        val d = aDigits[digit] - bDigits[digit] - borrow
        var max = sub(digit - 1, restK, if (d < 0) 1 else 0) * 10 + (10 + d) % 10
        if (restK > 0) {
            val s = sub(digit - 1, restK - 1, 0) * 10 + (10 + d) % 10
            if (max < s) max = s
        }
        memo[borrow][restK][digit] = max
        return max
    }
    return sub(aDigits.lastIndex, k)
}
