function Main(input) {
    input = input.trim().split(" ");
    var N = parseInt(input[0],10);
    var K = parseInt(input[1],10);

    if (K == 1) {
        console.log(0);
    }
    else {
        console.log(N - K);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));