"use strict"
function main(arg) {
    var arg = arg.trim().split("\n")[0].split(" ").map(Number)
    var N = arg[0]
    var K = arg[1]
    
    if (K === 1) {
        console.log(0)
        return
    }
    console.log(N - K)
    return
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));